]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make streams movable and swappable.
authorJonathan Wakely <jwakely@redhat.com>
Mon, 22 Sep 2014 13:34:09 +0000 (14:34 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 22 Sep 2014 13:34:09 +0000 (14:34 +0100)
PR libstdc++/54316
PR libstdc++/53626
* config/abi/pre/gnu.ver: Add new exports.
* config/io/basic_file_stdio.h (__basic_file): Support moving and
swapping.
* include/bits/basic_ios.h (basic_ios::move, basic_ios::swap):
Likewise.
* include/bits/ios_base.h (ios_base::_M_move, ios_base::_M_swap):
Likewise.
* include/bits/fstream.tcc (basic_filebuf): Likewise.
* include/bits/move.h (__exchange): Define for C++11 mode.
* include/ext/stdio_filebuf.h (stdio_filebuf): Support moving and
swapping.
* include/ext/stdio_sync_filebuf.h (stdio_sync_filebuf): Likewise.
* include/std/fstream (basic_filebuf, basic_ifstream, basic_ofstream,
basic_fstream): Likewise.
* include/std/ios: Remove whitespace.
* include/std/istream (basic_istream, basic_iostream): Support moving
and swapping.
* include/std/ostream (basic_ostream): Likewise.
* include/std/sstream (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/streambuf (basic_streambuf): Do not default copy
constructor and assignment on first declaration.
* include/std/utility (exchange): Forward to __exchange.
* testsuite/27_io/basic_filebuf/cons/char/copy_neg.cc: New.
* src/c++11/Makefile.am: Add stream-related files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/ext11-inst.cc (stdio_filebuf, stdio_sync_filebuf):
New file for explicit instantiation definitions.
* src/c++11/ios.cc: Move from src/c++98 to here.
(ios_base::_M_move, ios_base::_M_swap): Define.
* src/c++11/ios-inst.cc: Move from src/c++98 to here.
* src/c++11/iostream-inst.cc: Likewise.
* src/c++11/istream-inst.cc: Likewise.
* src/c++11/ostream-inst.cc: Likewise.
* src/c++11/sstream-inst.cc: Likewise.
* src/c++11/streambuf-inst.cc: Likewise.
* src/c++98/Makefile.am: Remove stream-related files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/ext-inst.cc (stdio_filebuf): Remove explicit
instantiations.
* src/c++98/misc-inst.cc (stdio_sync_filebuf): Likewise.
* src/c++98/ios-inst.cc: Move to src/c++11/.
* src/c++98/ios.cc: Move to src/c++11/.
* src/c++98/iostream-inst.cc: Likewise.
* src/c++98/istream-inst.cc: Likewise.
* src/c++98/ostream-inst.cc: Likewise.
* src/c++98/sstream-inst.cc: Likewise.
* src/c++98/streambuf-inst.cc: Likewise.
* testsuite/27_io/basic_filebuf/cons/char/copy_neg.cc: New.
* testsuite/27_io/basic_fstream/cons/move.cc: New.
* testsuite/27_io/basic_fstream/assign/1.cc: New.
* testsuite/27_io/basic_ifstream/cons/move.cc: New.
* testsuite/27_io/basic_ifstream/assign/1.cc: New.
* testsuite/27_io/basic_istringstream/assign/1.cc: New.
* testsuite/27_io/basic_istringstream/cons/move.cc: New.
* testsuite/27_io/basic_ofstream/cons/move.cc: New.
* testsuite/27_io/basic_ofstream/assign/1.cc: New.
* testsuite/27_io/basic_ostringstream/assign/1.cc: New.
* testsuite/27_io/basic_ostringstream/cons/move.cc: New.
* testsuite/27_io/basic_stringstream/assign/1.cc: New.
* testsuite/27_io/basic_stringstream/cons/move.cc: New.

From-SVN: r215463

43 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/config/io/basic_file_stdio.h
libstdc++-v3/include/bits/basic_ios.h
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/ios_base.h
libstdc++-v3/include/bits/move.h
libstdc++-v3/include/ext/stdio_filebuf.h
libstdc++-v3/include/ext/stdio_sync_filebuf.h
libstdc++-v3/include/std/fstream
libstdc++-v3/include/std/ios
libstdc++-v3/include/std/istream
libstdc++-v3/include/std/ostream
libstdc++-v3/include/std/sstream
libstdc++-v3/include/std/streambuf
libstdc++-v3/include/std/utility
libstdc++-v3/src/c++11/Makefile.am
libstdc++-v3/src/c++11/Makefile.in
libstdc++-v3/src/c++11/ext11-inst.cc [new file with mode: 0644]
libstdc++-v3/src/c++11/ios-inst.cc [moved from libstdc++-v3/src/c++98/ios-inst.cc with 100% similarity]
libstdc++-v3/src/c++11/ios.cc [moved from libstdc++-v3/src/c++98/ios.cc with 73% similarity]
libstdc++-v3/src/c++11/iostream-inst.cc [moved from libstdc++-v3/src/c++98/iostream-inst.cc with 100% similarity]
libstdc++-v3/src/c++11/istream-inst.cc [moved from libstdc++-v3/src/c++98/istream-inst.cc with 100% similarity]
libstdc++-v3/src/c++11/ostream-inst.cc [moved from libstdc++-v3/src/c++98/ostream-inst.cc with 100% similarity]
libstdc++-v3/src/c++11/sstream-inst.cc [moved from libstdc++-v3/src/c++98/sstream-inst.cc with 100% similarity]
libstdc++-v3/src/c++11/streambuf-inst.cc [moved from libstdc++-v3/src/c++98/streambuf-inst.cc with 100% similarity]
libstdc++-v3/src/c++98/Makefile.am
libstdc++-v3/src/c++98/Makefile.in
libstdc++-v3/src/c++98/ext-inst.cc
libstdc++-v3/src/c++98/misc-inst.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/cons/char/copy_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_fstream/assign/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_fstream/cons/move.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_ifstream/assign/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_ifstream/cons/move.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_istringstream/assign/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_istringstream/cons/move.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_ofstream/assign/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_ofstream/cons/move.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_ostringstream/assign/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/move.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_stringstream/assign/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/basic_stringstream/cons/move.cc [new file with mode: 0644]

index 7682e279876732f3c539c2bc5186e45a47cfdf11..04749d772b0b44727021f6cdc7ace34f3bc3ad49 100644 (file)
@@ -1,3 +1,69 @@
+2014-09-19  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/54316
+       PR libstdc++/53626
+       * config/abi/pre/gnu.ver: Add new exports.
+       * config/io/basic_file_stdio.h (__basic_file): Support moving and
+       swapping.
+       * include/bits/basic_ios.h (basic_ios::move, basic_ios::swap):
+       Likewise.
+       * include/bits/ios_base.h (ios_base::_M_move, ios_base::_M_swap):
+       Likewise.
+       * include/bits/fstream.tcc (basic_filebuf): Likewise.
+       * include/bits/move.h (__exchange): Define for C++11 mode.
+       * include/ext/stdio_filebuf.h (stdio_filebuf): Support moving and
+       swapping.
+       * include/ext/stdio_sync_filebuf.h (stdio_sync_filebuf): Likewise.
+       * include/std/fstream (basic_filebuf, basic_ifstream, basic_ofstream,
+       basic_fstream): Likewise.
+       * include/std/ios: Remove whitespace.
+       * include/std/istream (basic_istream, basic_iostream): Support moving
+       and swapping.
+       * include/std/ostream (basic_ostream): Likewise.
+       * include/std/sstream (basic_stringbuf, basic_istringstream,
+       basic_ostringstream, basic_stringstream): Likewise.
+       * include/std/streambuf (basic_streambuf): Do not default copy
+       constructor and assignment on first declaration.
+       * include/std/utility (exchange): Forward to __exchange.
+       * testsuite/27_io/basic_filebuf/cons/char/copy_neg.cc: New.
+       * src/c++11/Makefile.am: Add stream-related files.
+       * src/c++11/Makefile.in: Regenerate.
+       * src/c++11/ext11-inst.cc (stdio_filebuf, stdio_sync_filebuf):
+       New file for explicit instantiation definitions.
+       * src/c++11/ios.cc: Move from src/c++98 to here.
+       (ios_base::_M_move, ios_base::_M_swap): Define.
+       * src/c++11/ios-inst.cc: Move from src/c++98 to here.
+       * src/c++11/iostream-inst.cc: Likewise.
+       * src/c++11/istream-inst.cc: Likewise.
+       * src/c++11/ostream-inst.cc: Likewise.
+       * src/c++11/sstream-inst.cc: Likewise.
+       * src/c++11/streambuf-inst.cc: Likewise.
+       * src/c++98/Makefile.am: Remove stream-related files.
+       * src/c++98/Makefile.in: Regenerate.
+       * src/c++98/ext-inst.cc (stdio_filebuf): Remove explicit
+       instantiations.
+       * src/c++98/misc-inst.cc (stdio_sync_filebuf): Likewise.
+       * src/c++98/ios-inst.cc: Move to src/c++11/.
+       * src/c++98/ios.cc: Move to src/c++11/.
+       * src/c++98/iostream-inst.cc: Likewise.
+       * src/c++98/istream-inst.cc: Likewise.
+       * src/c++98/ostream-inst.cc: Likewise.
+       * src/c++98/sstream-inst.cc: Likewise.
+       * src/c++98/streambuf-inst.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/cons/char/copy_neg.cc: New.
+       * testsuite/27_io/basic_fstream/cons/move.cc: New.
+       * testsuite/27_io/basic_fstream/assign/1.cc: New.
+       * testsuite/27_io/basic_ifstream/cons/move.cc: New.
+       * testsuite/27_io/basic_ifstream/assign/1.cc: New.
+       * testsuite/27_io/basic_istringstream/assign/1.cc: New.
+       * testsuite/27_io/basic_istringstream/cons/move.cc: New.
+       * testsuite/27_io/basic_ofstream/cons/move.cc: New.
+       * testsuite/27_io/basic_ofstream/assign/1.cc: New.
+       * testsuite/27_io/basic_ostringstream/assign/1.cc: New.
+       * testsuite/27_io/basic_ostringstream/cons/move.cc: New.
+       * testsuite/27_io/basic_stringstream/assign/1.cc: New.
+       * testsuite/27_io/basic_stringstream/cons/move.cc: New.
+
 2014-09-17  Jason Merrill  <jason@redhat.com>
 
        * libsupc++/dyncast.cc (__dynamic_cast): Handle mid-destruction
index 41fac71adaf95652b6c068dbd4e6d2b00776f121..669e36d7eceb151fdf88b59bf3dc65691adda6c5 100644 (file)
@@ -989,7 +989,8 @@ GLIBCXX_3.4.10 {
     _ZNSt15basic_streambufI[cw]St11char_traitsI[cw]EE6stosscEv;
 
     _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EE4syncEv;
-    _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EE[5-9C]*;
+    _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EE[5-9]*;
+    _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEC[12]EP*;
     _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EED[^2]*;
 
 } GLIBCXX_3.4.9;
@@ -1375,6 +1376,47 @@ GLIBCXX_3.4.21 {
     # void std::thread::_M_start_thread(__shared_base_type, void(*)())
     _ZNSt6thread15_M_start_threadESt10shared_ptrINS_10_Impl_baseEEPFvvE;
 
+    # Move/swap functions for iostreams
+    _ZNSt8ios_base7_M_swapERS_;
+    _ZNSt8ios_base7_M_moveERS_;
+    _ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE4moveE[OR]S2_;
+    _ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE4swapERS2_;
+    _ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE9set_rdbuf*;
+    _ZNSt15basic_streambufI[cw]St11char_traitsI[cw]EE4swapERS2_;
+    _ZNS[dio]4swapERS[dio];
+    _ZNS[dio]aSEOS[dio];
+    _ZNS[dio]C[12]EOS[dio];
+    _ZNSt13basic_[io]streamIwSt11char_traitsIwEE4swapERS2_;
+    _ZNSt13basic_[io]streamIwSt11char_traitsIwEEaSEOS2_;
+    _ZNSt13basic_[io]streamIwSt11char_traitsIwEEC[12]EOS2_;
+    _ZNSt14basic_iostreamIwSt11char_traitsIwEE4swapERS2_;
+    _ZNSt14basic_iostreamIwSt11char_traitsIwEEaSEOS2_;
+    _ZNSt14basic_iostreamIwSt11char_traitsIwEEC[12]EOS2_;
+    _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EE4swapERS2_;
+    _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EEaSEOS2_;
+    _ZNSt13basic_filebufI[cw]St11char_traitsI[cw]EEC[12]EOS2_;
+    _ZNSt13basic_fstreamI[cw]St11char_traitsI[cw]EE4swapERS2_;
+    _ZNSt13basic_fstreamI[cw]St11char_traitsI[cw]EEaSEOS2_;
+    _ZNSt13basic_fstreamI[cw]St11char_traitsI[cw]EEC[12]EOS2_;
+    _ZNSt14basic_[io]fstreamI[cw]St11char_traitsI[cw]EE4swapERS2_;
+    _ZNSt14basic_[io]fstreamI[cw]St11char_traitsI[cw]EEaSEOS2_;
+    _ZNSt14basic_[io]fstreamI[cw]St11char_traitsI[cw]EEC[12]EOS2_;
+    _ZNSt15basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EE4swapERS3_;
+    _ZNSt15basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEaSEOS3_;
+    _ZNSt15basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]EOS3_;
+    _ZNSt18basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4swapERS3_;
+    _ZNSt18basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEaSEOS3_;
+    _ZNSt18basic_stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]EOS3_;
+    _ZNSt19basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EE4swapERS3_;
+    _ZNSt19basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEaSEOS3_;
+    _ZNSt19basic_[io]stringstreamI[cw]St11char_traitsI[cw]ESaI[cw]EEC[12]EOS3_;
+    _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEaSEOS3_;
+    _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEC[12]EOS3_;
+
+    # basic_ostream<C,T>::basic_ostream(basic_iostream<C,T>*)
+    _ZNSoC[12]EPSd;
+    _ZNSt13basic_ostreamIwSt11char_traitsIwEEC[12]EPSt14basic_iostreamIwS1_E;
+
 } GLIBCXX_3.4.20;
 
 
index b457ec5bb9aa0bbb5be91cf3e02f250091480af9..f58164e131fd23c202c2ad7b6b1c6d1db88143cc 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <bits/c++config.h>
 #include <bits/c++io.h>  // for __c_lock and __c_file
+#include <bits/move.h>   // for swap
 #include <ios>
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -61,6 +62,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     public:
       __basic_file(__c_lock* __lock = 0) throw ();
 
+#if __cplusplus >= 201103L
+      __basic_file(__basic_file&& __rv, __c_lock* __lock = 0) noexcept
+      : _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created)
+      {
+       __rv._M_cfile = nullptr;
+       __rv._M_cfile_created = false;
+      }
+
+      __basic_file& operator=(const __basic_file&) = delete;
+      __basic_file& operator=(__basic_file&&) = delete;
+
+      void
+      swap(__basic_file& __f) noexcept
+      {
+       std::swap(_M_cfile, __f._M_cfile);
+       std::swap(_M_cfile_created, __f._M_cfile_created);
+      }
+#endif
+
       __basic_file* 
       open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
 
index 58bede4d7598a243e4f3e2bd2521cd83154607f7..10263ed07a42e79fc95e6b1eb4cc6a97be413b49 100644 (file)
@@ -36,6 +36,7 @@
 #include <bits/locale_classes.h>
 #include <bits/locale_facets.h>
 #include <bits/streambuf_iterator.h>
+#include <bits/move.h>
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -465,6 +466,41 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       void
       init(basic_streambuf<_CharT, _Traits>* __sb);
 
+#if __cplusplus >= 201103L
+      basic_ios(const basic_ios&) = delete;
+      basic_ios& operator=(const basic_ios&) = delete;
+
+      void
+      move(basic_ios& __rhs)
+      {
+       ios_base::_M_move(__rhs);
+       _M_cache_locale(_M_ios_locale);
+       this->tie(__rhs.tie(nullptr));
+       _M_fill = __rhs._M_fill;
+       _M_fill_init = __rhs._M_fill_init;
+       _M_streambuf = nullptr;
+      }
+
+      void
+      move(basic_ios&& __rhs)
+      { this->move(__rhs); }
+
+      void
+      swap(basic_ios& __rhs) noexcept
+      {
+       ios_base::_M_swap(__rhs);
+       _M_cache_locale(_M_ios_locale);
+       __rhs._M_cache_locale(__rhs._M_ios_locale);
+       std::swap(_M_tie, __rhs._M_tie);
+       std::swap(_M_fill, __rhs._M_fill);
+       std::swap(_M_fill_init, __rhs._M_fill_init);
+      }
+
+      void
+      set_rdbuf(basic_streambuf<_CharT, _Traits>* __sb)
+      { _M_streambuf = __sb; }
+#endif
+
       void
       _M_cache_locale(const locale& __loc);
     };
index 21a67cdae979fcd13cd5db4831a11823a9f3505e..b0404ea8dbd0a8a4fdf515f4942d4a807d76f0cc 100644 (file)
@@ -37,6 +37,7 @@
 #pragma GCC system_header
 
 #include <bits/cxxabi_forced.h>
+#include <bits/move.h>   // for swap
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -88,6 +89,90 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
     }
 
+#if __cplusplus >= 201103L
+  template<typename _CharT, typename _Traits>
+    basic_filebuf<_CharT, _Traits>::
+    basic_filebuf(basic_filebuf&& __rhs)
+    : __streambuf_type(__rhs),
+    _M_lock(), _M_file(std::move(__rhs._M_file), &_M_lock),
+    _M_mode(std::__exchange(__rhs._M_mode, ios_base::openmode(0))),
+    _M_state_beg(std::move(__rhs._M_state_beg)),
+    _M_state_cur(std::move(__rhs._M_state_cur)),
+    _M_state_last(std::move(__rhs._M_state_last)),
+    _M_buf(std::__exchange(__rhs._M_buf, nullptr)),
+    _M_buf_size(std::__exchange(__rhs._M_buf_size, 1)),
+    _M_buf_allocated(std::__exchange(__rhs._M_buf_allocated, false)),
+    _M_reading(std::__exchange(__rhs._M_reading, false)),
+    _M_writing(std::__exchange(__rhs._M_writing, false)),
+    _M_pback(__rhs._M_pback),
+    _M_pback_cur_save(std::__exchange(__rhs._M_pback_cur_save, nullptr)),
+    _M_pback_end_save(std::__exchange(__rhs._M_pback_end_save, nullptr)),
+    _M_pback_init(std::__exchange(__rhs._M_pback_init, false)),
+    _M_codecvt(__rhs._M_codecvt),
+    _M_ext_buf(std::__exchange(__rhs._M_ext_buf, nullptr)),
+    _M_ext_buf_size(std::__exchange(__rhs._M_ext_buf_size, 0)),
+    _M_ext_next(std::__exchange(__rhs._M_ext_next, nullptr)),
+    _M_ext_end(std::__exchange(__rhs._M_ext_end, nullptr))
+    {
+      __rhs._M_set_buffer(-1);
+      __rhs._M_state_last = __rhs._M_state_cur = __rhs._M_state_beg;
+    }
+
+  template<typename _CharT, typename _Traits>
+    basic_filebuf<_CharT, _Traits>&
+    basic_filebuf<_CharT, _Traits>::
+    operator=(basic_filebuf&& __rhs)
+    {
+      this->close();
+      __streambuf_type::operator=(__rhs);
+      _M_file.swap(__rhs._M_file);
+      _M_mode = std::__exchange(__rhs._M_mode, ios_base::openmode(0));
+      _M_state_beg = std::move(__rhs._M_state_beg);
+      _M_state_cur = std::move(__rhs._M_state_cur);
+      _M_state_last = std::move(__rhs._M_state_last);
+      _M_buf = std::__exchange(__rhs._M_buf, nullptr);
+      _M_buf_size = std::__exchange(__rhs._M_buf_size, 1);
+      _M_buf_allocated = std::__exchange(__rhs._M_buf_allocated, false);
+      _M_ext_buf = std::__exchange(__rhs._M_ext_buf, nullptr);
+      _M_ext_buf_size = std::__exchange(__rhs._M_ext_buf_size, 0);
+      _M_ext_next = std::__exchange(__rhs._M_ext_next, nullptr);
+      _M_ext_end = std::__exchange(__rhs._M_ext_end, nullptr);
+      _M_reading = std::__exchange(__rhs._M_reading, false);
+      _M_writing = std::__exchange(__rhs._M_writing, false);
+      _M_pback_cur_save = std::__exchange(__rhs._M_pback_cur_save, nullptr);
+      _M_pback_end_save = std::__exchange(__rhs._M_pback_end_save, nullptr);
+      _M_pback_init = std::__exchange(__rhs._M_pback_init, false);
+      __rhs._M_set_buffer(-1);
+      __rhs._M_state_last = __rhs._M_state_cur = __rhs._M_state_beg;
+      return *this;
+    }
+
+  template<typename _CharT, typename _Traits>
+    void
+    basic_filebuf<_CharT, _Traits>::
+    swap(basic_filebuf& __rhs)
+    {
+      __streambuf_type::swap(__rhs);
+      _M_file.swap(__rhs._M_file);
+      std::swap(_M_mode, __rhs._M_mode);
+      std::swap(_M_state_beg, __rhs._M_state_beg);
+      std::swap(_M_state_cur, __rhs._M_state_cur);
+      std::swap(_M_state_last, __rhs._M_state_last);
+      std::swap(_M_buf, __rhs._M_buf);
+      std::swap(_M_buf_size, __rhs._M_buf_size);
+      std::swap(_M_buf_allocated, __rhs._M_buf_allocated);
+      std::swap(_M_ext_buf, __rhs._M_ext_buf);
+      std::swap(_M_ext_buf_size, __rhs._M_ext_buf_size);
+      std::swap(_M_ext_next, __rhs._M_ext_next);
+      std::swap(_M_ext_end, __rhs._M_ext_end);
+      std::swap(_M_reading, __rhs._M_reading);
+      std::swap(_M_writing, __rhs._M_writing);
+      std::swap(_M_pback_cur_save, __rhs._M_pback_cur_save);
+      std::swap(_M_pback_end_save, __rhs._M_pback_end_save);
+      std::swap(_M_pback_init, __rhs._M_pback_init);
+    }
+#endif
+
   template<typename _CharT, typename _Traits>
     typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
     basic_filebuf<_CharT, _Traits>::
index 4aade6855fbfabf1a6cb0501dd73e6d95124bbc8..fb448fd1091d893e932eae237aeb066d9ce135dc 100644 (file)
@@ -794,6 +794,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     ios_base&
     operator=(const ios_base&) = delete;
+
+  protected:
+    void
+    _M_move(ios_base&) noexcept;
+
+    void
+    _M_swap(ios_base& __rhs) noexcept;
 #endif
   };
 
index dc4ac0fea5877be809832100f7ebc0ff9e12465d..2fd0d37e2edffa158bd8e17bbc98ed406e2869ec 100644 (file)
@@ -135,6 +135,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     addressof(_Tp& __r) noexcept
     { return std::__addressof(__r); }
 
+  // C++11 version of std::exchange for internal use.
+  template <typename _Tp, typename _Up = _Tp>
+    inline _Tp
+    __exchange(_Tp& __obj, _Up&& __new_val)
+    {
+      _Tp __old_val = std::move(__obj);
+      __obj = std::forward<_Up>(__new_val);
+      return __old_val;
+    }
+
   /// @} group utilities
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
index 28741637f846e9e20d40412514853347897bf026..8d0169021749165cfd06fbf0c3bfcac77bd578d7 100644 (file)
@@ -97,6 +97,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       virtual
       ~stdio_filebuf();
 
+#if __cplusplus >= 201103L
+      stdio_filebuf(stdio_filebuf&&) = default;
+      stdio_filebuf& operator=(stdio_filebuf&&) = default;
+
+      void
+      swap(stdio_filebuf& __fb)
+      { std::basic_filebuf<_CharT, _Traits>::swap(__fb); }
+#endif
+
       /**
        *  @return  The underlying file descriptor.
        *
index 73283a74b9f203ade2a7271b0083aff8f36d56b3..c881172aae33d1e3f58d0f4b8e0696fb460f83c9 100644 (file)
@@ -35,6 +35,7 @@
 #include <unistd.h>
 #include <cstdio>
 #include <bits/c++io.h>  // For __c_file
+#include <bits/move.h>   // For __exchange
 
 #ifdef _GLIBCXX_USE_WCHAR_T
 #include <cwchar>
@@ -64,8 +65,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef typename traits_type::off_type           off_type;
 
     private:
+      typedef std::basic_streambuf<_CharT, _Traits> __streambuf_type;
+
       // Underlying stdio FILE
-      std::__c_file* const _M_file;
+      std::__c_file* _M_file;
 
       // Last character gotten. This is used when pbackfail is
       // called from basic_streambuf::sungetc()
@@ -77,6 +80,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       : _M_file(__f), _M_unget_buf(traits_type::eof())
       { }
 
+#if __cplusplus >= 201103L
+      stdio_sync_filebuf(stdio_sync_filebuf&& __fb) noexcept
+      : __streambuf_type(std::move(__fb)),
+      _M_file(__fb._M_file), _M_unget_buf(__fb._M_unget_buf)
+      {
+       __fb._M_file = nullptr;
+       __fb._M_unget_buf = traits_type::eof();
+      }
+
+      stdio_sync_filebuf&
+      operator=(stdio_sync_filebuf&& __fb) noexcept
+      {
+       __streambuf_type::operator=(__fb);
+       _M_file = std::__exchange(__fb._M_file, nullptr);
+       _M_unget_buf = std::__exchange(__fb._M_unget_buf, traits_type::eof());
+       return *this;
+      }
+
+      void
+      swap(stdio_sync_filebuf& __fb)
+      {
+       __streambuf_type::swap(__fb);
+       std::swap(_M_file, __fb._M_file);
+       std::swap(_M_unget_buf, __fb._M_unget_buf);
+      }
+#endif
+
       /**
        *  @return  The underlying FILE*.
        *
index 4d802f153a464c3761f7c8483d11e57eab8ab394..fcf5f94e36ee51cd4deecd665d402a67d5f6adc2 100644 (file)
@@ -125,7 +125,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __state_type             _M_state_last;
 
       /// Pointer to the beginning of internal buffer.
-      char_type*               _M_buf;         
+      char_type*               _M_buf;
 
       /**
        *  Actual size of internal buffer. This number is equal to the size
@@ -226,6 +226,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       basic_filebuf();
 
+#if __cplusplus >= 201103L
+      basic_filebuf(const basic_filebuf&) = delete;
+      basic_filebuf(basic_filebuf&&);
+#endif
+
       /**
        *  @brief  The destructor closes the file first.
        */
@@ -233,6 +238,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ~basic_filebuf()
       { this->close(); }
 
+#if __cplusplus >= 201103L
+      basic_filebuf& operator=(const basic_filebuf&) = delete;
+      basic_filebuf& operator=(basic_filebuf&&);
+      void swap(basic_filebuf&);
+#endif
+
       // Members:
       /**
        *  @brief  Returns true if the external file is open.
@@ -504,6 +515,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        this->init(&_M_filebuf);
        this->open(__s, __mode);
       }
+
+      basic_ifstream(const basic_ifstream&) = delete;
+
+      basic_ifstream(basic_ifstream&& __rhs)
+      : __istream_type(std::move(__rhs)),
+      _M_filebuf(std::move(__rhs._M_filebuf))
+      { __istream_type::set_rdbuf(&_M_filebuf); }
 #endif
 
       /**
@@ -515,6 +533,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ~basic_ifstream()
       { }
 
+#if __cplusplus >= 201103L
+      // 27.8.3.2 Assign and swap:
+
+      basic_ifstream&
+      operator=(const basic_ifstream&) = delete;
+
+      basic_ifstream&
+      operator=(basic_ifstream&& __rhs)
+      {
+       __istream_type::operator=(std::move(__rhs));
+       _M_filebuf = std::move(__rhs._M_filebuf);
+       return *this;
+      }
+
+      void
+      swap(basic_ifstream& __rhs)
+      {
+       __istream_type::swap(__rhs);
+       _M_filebuf.swap(__rhs._M_filebuf);
+      }
+#endif
+
       // Members:
       /**
        *  @brief  Accessing the underlying buffer.
@@ -679,6 +719,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        this->init(&_M_filebuf);
        this->open(__s, __mode);
       }
+
+      basic_ofstream(const basic_ofstream&) = delete;
+
+      basic_ofstream(basic_ofstream&& __rhs)
+      : __ostream_type(std::move(__rhs)),
+      _M_filebuf(std::move(__rhs._M_filebuf))
+      { __ostream_type::set_rdbuf(&_M_filebuf); }
 #endif
 
       /**
@@ -690,6 +737,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ~basic_ofstream()
       { }
 
+#if __cplusplus >= 201103L
+      // 27.8.3.2 Assign and swap:
+
+      basic_ofstream&
+      operator=(const basic_ofstream&) = delete;
+
+      basic_ofstream&
+      operator=(basic_ofstream&& __rhs)
+      {
+       __ostream_type::operator=(std::move(__rhs));
+       _M_filebuf = std::move(__rhs._M_filebuf);
+       return *this;
+      }
+
+      void
+      swap(basic_ofstream& __rhs)
+      {
+       __ostream_type::swap(__rhs);
+       _M_filebuf.swap(__rhs._M_filebuf);
+      }
+#endif
+
       // Members:
       /**
        *  @brief  Accessing the underlying buffer.
@@ -852,6 +921,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        this->init(&_M_filebuf);
        this->open(__s, __mode);
       }
+
+      basic_fstream(const basic_fstream&) = delete;
+
+      basic_fstream(basic_fstream&& __rhs)
+      : __iostream_type(std::move(__rhs)),
+      _M_filebuf(std::move(__rhs._M_filebuf))
+      { __iostream_type::set_rdbuf(&_M_filebuf); }
 #endif
 
       /**
@@ -863,6 +939,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ~basic_fstream()
       { }
 
+#if __cplusplus >= 201103L
+      // 27.8.3.2 Assign and swap:
+
+      basic_fstream&
+      operator=(const basic_fstream&) = delete;
+
+      basic_fstream&
+      operator=(basic_fstream&& __rhs)
+      {
+       __iostream_type::operator=(std::move(__rhs));
+       _M_filebuf = std::move(__rhs._M_filebuf);
+       return *this;
+      }
+
+      void
+      swap(basic_fstream& __rhs)
+      {
+       __iostream_type::swap(__rhs);
+       _M_filebuf.swap(__rhs._M_filebuf);
+      }
+#endif
+
       // Members:
       /**
        *  @brief  Accessing the underlying buffer.
@@ -947,6 +1045,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
     };
 
+#if __cplusplus >= 201103L
+  /// Swap specialization for filebufs.
+  template <class _CharT, class _Traits>
+    inline void
+    swap(basic_filebuf<_CharT, _Traits>& __x,
+        basic_filebuf<_CharT, _Traits>& __y)
+    { __x.swap(__y); }
+
+  /// Swap specialization for ifstreams.
+  template <class _CharT, class _Traits>
+    inline void
+    swap(basic_ifstream<_CharT, _Traits>& __x,
+        basic_ifstream<_CharT, _Traits>& __y)
+    { __x.swap(__y); }
+
+  /// Swap specialization for ofstreams.
+  template <class _CharT, class _Traits>
+    inline void
+    swap(basic_ofstream<_CharT, _Traits>& __x,
+        basic_ofstream<_CharT, _Traits>& __y)
+    { __x.swap(__y); }
+
+  /// Swap specialization for fstreams.
+  template <class _CharT, class _Traits>
+    inline void
+    swap(basic_fstream<_CharT, _Traits>& __x,
+        basic_fstream<_CharT, _Traits>& __y)
+    { __x.swap(__y); }
+#endif
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
index 5d69c4be3d26530ff453d86e433acc97cf60d5e9..acfd7c20ae8f45a59598bbc769c8fd71ab9e1def 100644 (file)
@@ -40,7 +40,7 @@
 #include <bits/char_traits.h>  // For char_traits, streamoff, streamsize, fpos
 #include <bits/localefwd.h>    // For class locale
 #include <bits/ios_base.h>     // For ios_base declarations.
-#include <streambuf> 
+#include <streambuf>
 #include <bits/basic_ios.h>
 
 #endif /* _GLIBCXX_IOS */
index f0637680d3b9d29a6342c84a95bf7b6e9fa0c8b4..3a4761624e297ae9635620e874e63348f1ad656a 100644 (file)
@@ -607,6 +607,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       : _M_gcount(streamsize(0))
       { this->init(0); }
 
+#if __cplusplus >= 201103L
+      basic_istream(const basic_istream&) = delete;
+
+      basic_istream(basic_istream&& __rhs)
+      : __ios_type(), _M_gcount(__rhs._M_gcount)
+      {
+       __ios_type::move(__rhs);
+       __rhs._M_gcount = 0;
+      }
+
+      // 27.7.3.3 Assign/swap
+
+      basic_istream& operator=(const basic_istream&) = delete;
+
+      basic_istream&
+      operator=(basic_istream&& __rhs)
+      {
+       swap(__rhs);
+       return *this;
+      }
+
+      void
+      swap(basic_istream& __rhs)
+      {
+       __ios_type::swap(__rhs);
+       std::swap(_M_gcount, __rhs._M_gcount);
+      }
+#endif
+
       template<typename _ValueT>
        __istream_type&
        _M_extract(_ValueT& __v);
@@ -829,6 +858,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     protected:
       basic_iostream()
       : __istream_type(), __ostream_type() { }
+
+#if __cplusplus >= 201103L
+      basic_iostream(const basic_iostream&) = delete;
+
+      basic_iostream(basic_iostream&& __rhs)
+      : __istream_type(std::move(__rhs)), __ostream_type(this)
+      { }
+
+      // 27.7.3.3 Assign/swap
+
+      basic_iostream& operator=(const basic_iostream&) = delete;
+
+      basic_iostream&
+      operator=(basic_iostream&& __rhs)
+      {
+       swap(__rhs);
+       return *this;
+      }
+
+      void
+      swap(basic_iostream& __rhs)
+      { __istream_type::swap(__rhs); }
+#endif
     };
 
   /**
index a25b3d033e675ec687c8bcd464f7fde7bcda6ce9..748b805ee7d66ed0e7d630166aa9421348da1620 100644 (file)
@@ -384,6 +384,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       basic_ostream()
       { this->init(0); }
 
+#if __cplusplus >= 201103L
+      // Non-standard constructor that does not call init()
+      basic_ostream(basic_iostream<_CharT, _Traits>*) { }
+
+      basic_ostream(const basic_ostream&) = delete;
+
+      basic_ostream(basic_ostream&& __rhs)
+      : __ios_type()
+      { __ios_type::move(__rhs); }
+
+      // 27.7.3.3 Assign/swap
+
+      basic_ostream& operator=(const basic_ostream&) = delete;
+
+      basic_ostream&
+      operator=(basic_ostream&& __rhs)
+      {
+       swap(__rhs);
+       return *this;
+      }
+
+      void
+      swap(basic_ostream& __rhs)
+      { __ios_type::swap(__rhs); }
+#endif
+
       template<typename _ValueT>
        __ostream_type&
        _M_insert(_ValueT __v);
index f97caba14ae5de3d248cf9d737b6a94cea2e2b0f..f074edaf2e1dcd645e7aff255398d9e90ec33430 100644 (file)
@@ -113,6 +113,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       : __streambuf_type(), _M_mode(), _M_string(__str.data(), __str.size())
       { _M_stringbuf_init(__mode); }
 
+#if __cplusplus >= 201103L
+      basic_stringbuf(const basic_stringbuf&) = delete;
+
+      basic_stringbuf(basic_stringbuf&& __rhs)
+      : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
+      _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string))
+      { __rhs._M_stringbuf_init(__rhs._M_mode); }
+
+      // 27.8.2.2 Assign and swap:
+
+      basic_stringbuf&
+      operator=(const basic_stringbuf&) = delete;
+
+      basic_stringbuf&
+      operator=(basic_stringbuf&& __rhs)
+      {
+       const __streambuf_type& __base = __rhs;
+       __streambuf_type::operator=(__base);
+       this->pubimbue(__rhs.getloc());
+       _M_mode = __rhs._M_mode;
+       _M_string = std::move(__rhs._M_string);
+       __rhs._M_stringbuf_init(__rhs._M_mode);
+       return *this;
+      }
+
+      void
+      swap(basic_stringbuf& __rhs)
+      {
+       __streambuf_type& __base = __rhs;
+       __streambuf_type::swap(__base);
+       __rhs.pubimbue(this->pubimbue(__rhs.getloc()));
+       std::swap(_M_mode, __rhs._M_mode);
+       std::swap(_M_string, __rhs._M_string);
+      }
+#endif
+
       // Get and set:
       /**
        *  @brief  Copying out the string buffer.
@@ -337,6 +373,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ~basic_istringstream()
       { }
 
+#if __cplusplus >= 201103L
+      basic_istringstream(const basic_istringstream&) = delete;
+
+      basic_istringstream(basic_istringstream&& __rhs)
+      : __istream_type(std::move(__rhs)),
+      _M_stringbuf(std::move(__rhs._M_stringbuf))
+      { __istream_type::set_rdbuf(&_M_stringbuf); }
+
+      // 27.8.3.2 Assign and swap:
+
+      basic_istringstream&
+      operator=(const basic_istringstream&) = delete;
+
+      basic_istringstream&
+      operator=(basic_istringstream&& __rhs)
+      {
+       __istream_type::operator=(std::move(__rhs));
+       _M_stringbuf = std::move(__rhs._M_stringbuf);
+       return *this;
+      }
+
+      void
+      swap(basic_istringstream& __rhs)
+      {
+       __istream_type::swap(__rhs);
+       _M_stringbuf.swap(__rhs._M_stringbuf);
+      }
+#endif
+
       // Members:
       /**
        *  @brief  Accessing the underlying buffer.
@@ -452,6 +517,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ~basic_ostringstream()
       { }
 
+#if __cplusplus >= 201103L
+      basic_ostringstream(const basic_ostringstream&) = delete;
+
+      basic_ostringstream(basic_ostringstream&& __rhs)
+      : __ostream_type(std::move(__rhs)),
+      _M_stringbuf(std::move(__rhs._M_stringbuf))
+      { __ostream_type::set_rdbuf(&_M_stringbuf); }
+
+      // 27.8.3.2 Assign and swap:
+
+      basic_ostringstream&
+      operator=(const basic_ostringstream&) = delete;
+
+      basic_ostringstream&
+      operator=(basic_ostringstream&& __rhs)
+      {
+       __ostream_type::operator=(std::move(__rhs));
+       _M_stringbuf = std::move(__rhs._M_stringbuf);
+       return *this;
+      }
+
+      void
+      swap(basic_ostringstream& __rhs)
+      {
+       __ostream_type::swap(__rhs);
+       _M_stringbuf.swap(__rhs._M_stringbuf);
+      }
+#endif
+
       // Members:
       /**
        *  @brief  Accessing the underlying buffer.
@@ -564,6 +658,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       ~basic_stringstream()
       { }
 
+#if __cplusplus >= 201103L
+      basic_stringstream(const basic_stringstream&) = delete;
+
+      basic_stringstream(basic_stringstream&& __rhs)
+      : __iostream_type(std::move(__rhs)),
+      _M_stringbuf(std::move(__rhs._M_stringbuf))
+      { __iostream_type::set_rdbuf(&_M_stringbuf); }
+
+      // 27.8.3.2 Assign and swap:
+
+      basic_stringstream&
+      operator=(const basic_stringstream&) = delete;
+
+      basic_stringstream&
+      operator=(basic_stringstream&& __rhs)
+      {
+       __iostream_type::operator=(std::move(__rhs));
+       _M_stringbuf = std::move(__rhs._M_stringbuf);
+       return *this;
+      }
+
+      void
+      swap(basic_stringstream& __rhs)
+      {
+       __iostream_type::swap(__rhs);
+       _M_stringbuf.swap(__rhs._M_stringbuf);
+      }
+#endif
+
       // Members:
       /**
        *  @brief  Accessing the underlying buffer.
@@ -594,6 +717,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { _M_stringbuf.str(__s); }
     };
 
+#if __cplusplus >= 201103L
+  /// Swap specialization for stringbufs.
+  template <class _CharT, class _Traits, class _Allocator>
+    inline void
+    swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
+        basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
+    { __x.swap(__y); }
+
+  /// Swap specialization for istringstreams.
+  template <class _CharT, class _Traits, class _Allocator>
+    inline void
+    swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
+        basic_istringstream<_CharT, _Traits, _Allocator>& __y)
+    { __x.swap(__y); }
+
+  /// Swap specialization for ostringstreams.
+  template <class _CharT, class _Traits, class _Allocator>
+    inline void
+    swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
+        basic_ostringstream<_CharT, _Traits, _Allocator>& __y)
+    { __x.swap(__y); }
+
+  /// Swap specialization for stringstreams.
+  template <class _CharT, class _Traits, class _Allocator>
+    inline void
+    swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
+        basic_stringstream<_CharT, _Traits, _Allocator>& __y)
+    { __x.swap(__y); }
+#endif
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
index d3aa0ee29b521bd8a6f14ad36324af79421f3078..fce165f4e386455be10c645a13f4d444bab47aea 100644 (file)
@@ -798,24 +798,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cplusplus < 201103L
     private:
-      // _GLIBCXX_RESOLVE_LIB_DEFECTS
-      // Side effect of DR 50.
-      basic_streambuf(const basic_streambuf& __sb)
-      : _M_in_beg(__sb._M_in_beg), _M_in_cur(__sb._M_in_cur),
-      _M_in_end(__sb._M_in_end), _M_out_beg(__sb._M_out_beg),
-      _M_out_cur(__sb._M_out_cur), _M_out_end(__sb._M_out_end),
-      _M_buf_locale(__sb._M_buf_locale)
-      { }
-
-      basic_streambuf&
-      operator=(const basic_streambuf&) { return *this; }
 #else
     protected:
-      basic_streambuf(const basic_streambuf&) = default;
+#endif
+      basic_streambuf(const basic_streambuf&);
 
       basic_streambuf&
-      operator=(const basic_streambuf&) = default;
+      operator=(const basic_streambuf&);
 
+#if __cplusplus >= 201103L
       void
       swap(basic_streambuf& __sb)
       {
@@ -830,6 +821,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
     };
 
+#if __cplusplus >= 201103L
+  template<typename _CharT, typename _Traits>
+    std::basic_streambuf<_CharT, _Traits>::
+    basic_streambuf(const basic_streambuf&) = default;
+
+  template<typename _CharT, typename _Traits>
+    std::basic_streambuf<_CharT, _Traits>&
+    std::basic_streambuf<_CharT, _Traits>::
+    operator=(const basic_streambuf&) = default;
+#endif
+
   // Explicit specialization declarations, defined in src/streambuf.cc.
   template<>
     streamsize
index 6d12839e509e63f40d3e304260e87dede7a636fe..cb7e1126ed08011dc1dc51bca64f3b538f0f5043 100644 (file)
@@ -191,11 +191,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template <typename _Tp, typename _Up = _Tp>
     inline _Tp
     exchange(_Tp& __obj, _Up&& __new_val)
-    {
-      _Tp __old_val = std::move(__obj);
-      __obj = std::forward<_Up>(__new_val);
-      return __old_val;
-    }
+    { return std::__exchange(__obj, std::forward<_Up>(__new_val)); }
 #endif
 
   // Stores a tuple of indices.  Used by tuple and pair, and by bind() to
index cf1e3beaa835a678be080112e7be1de6069b942a..39425d41c227d2bc718615e0842134be8bac9934 100644 (file)
@@ -36,6 +36,7 @@ sources = \
        future.cc \
        hash_c++0x.cc \
        hashtable_c++0x.cc \
+       ios.cc \
        limits.cc \
        mutex.cc \
        placeholders.cc \
@@ -49,7 +50,14 @@ sources = \
 if ENABLE_EXTERN_TEMPLATE
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 inst_sources = \
+       ext11-inst.cc \
        fstream-inst.cc \
+       ios-inst.cc \
+       iostream-inst.cc \
+       istream-inst.cc \
+       ostream-inst.cc \
+       sstream-inst.cc \
+       streambuf-inst.cc \
        string-inst.cc \
        wstring-inst.cc
 else
index 83b7bd155b9263d072c085e949a50c23effb9320..70c6c4b61fdcc133a23c7b67580db6cad24c5b63 100644 (file)
@@ -69,11 +69,15 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
 libc__11convenience_la_LIBADD =
 am__objects_1 = chrono.lo condition_variable.lo debug.lo \
        functexcept.lo functional.lo future.lo hash_c++0x.lo \
-       hashtable_c++0x.lo limits.lo mutex.lo placeholders.lo \
+       hashtable_c++0x.lo ios.lo limits.lo mutex.lo placeholders.lo \
        random.lo regex.lo shared_ptr.lo snprintf_lite.lo \
        system_error.lo thread.lo
-@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_2 = fstream-inst.lo \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  string-inst.lo wstring-inst.lo
+@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_2 = ext11-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  fstream-inst.lo ios-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  iostream-inst.lo istream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  ostream-inst.lo sstream-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  streambuf-inst.lo string-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  wstring-inst.lo
 am_libc__11convenience_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libc__11convenience_la_OBJECTS = $(am_libc__11convenience_la_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -319,6 +323,7 @@ sources = \
        future.cc \
        hash_c++0x.cc \
        hashtable_c++0x.cc \
+       ios.cc \
        limits.cc \
        mutex.cc \
        placeholders.cc \
@@ -334,7 +339,14 @@ sources = \
 
 # XTEMPLATE_FLAGS = -fno-implicit-templates
 @ENABLE_EXTERN_TEMPLATE_TRUE@inst_sources = \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  ext11-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  fstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  ios-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  iostream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  istream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  ostream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  sstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  streambuf-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  string-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  wstring-inst.cc
 
diff --git a/libstdc++-v3/src/c++11/ext11-inst.cc b/libstdc++-v3/src/c++11/ext11-inst.cc
new file mode 100644 (file)
index 0000000..5d4f95b
--- /dev/null
@@ -0,0 +1,40 @@
+// Explicit instantiation file.
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+#include <ext/stdio_filebuf.h>
+#include <ext/stdio_sync_filebuf.h>
+
+namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  template class stdio_filebuf<char>;
+  template class stdio_sync_filebuf<char>;
+#ifdef _GLIBCXX_USE_WCHAR_T
+  template class stdio_filebuf<wchar_t>;
+  template class stdio_sync_filebuf<wchar_t>;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
similarity index 73%
rename from libstdc++-v3/src/c++98/ios.cc
rename to libstdc++-v3/src/c++11/ios.cc
index b0fab28221d5f56d0cd076dcfa738752d9a69ae8..b5124ec6a276ef9225588439be6b3abd4421a35e 100644 (file)
@@ -187,5 +187,73 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _M_callbacks = 0;
   }
 
+  void
+  ios_base::_M_move(ios_base& __rhs) noexcept
+  {
+    _M_precision = __rhs._M_precision;
+    _M_width = __rhs._M_width;
+    _M_flags = __rhs._M_flags;
+    _M_exception = __rhs._M_exception;
+    _M_streambuf_state = __rhs._M_streambuf_state;
+    _M_callbacks = std::__exchange(__rhs._M_callbacks, nullptr);
+    if (_M_word != _M_local_word)
+       delete[] _M_word;
+    if (__rhs._M_word == __rhs._M_local_word)
+     {
+       _M_word = _M_local_word;
+       _M_word_size = _S_local_word_size;
+       for (int __i = 0; __i < _S_local_word_size; __i++)
+        _M_word[__i] = std::__exchange(__rhs._M_word[__i], {});
+     }
+    else
+     {
+       _M_word = std::__exchange(__rhs._M_word, __rhs._M_local_word);
+       _M_word_size
+        = std::__exchange(__rhs._M_word_size, _S_local_word_size);
+     }
+    _M_ios_locale = __rhs._M_ios_locale;
+  }
+
+  void
+  ios_base::_M_swap(ios_base& __rhs) noexcept
+  {
+    std::swap(_M_precision, __rhs._M_precision);
+    std::swap(_M_width, __rhs._M_width);
+    std::swap(_M_flags, __rhs._M_flags);
+    std::swap(_M_exception, __rhs._M_exception);
+    std::swap(_M_streambuf_state, __rhs._M_streambuf_state);
+    std::swap(_M_callbacks, __rhs._M_callbacks);
+    const bool __lhs_local = _M_word == _M_local_word;
+    const bool __rhs_local = __rhs._M_word == __rhs._M_local_word;
+    if (__lhs_local && __rhs_local)
+     std::swap(_M_local_word, __rhs._M_local_word); // array swap
+    else
+     {
+       if (!__lhs_local && !__lhs_local)
+        std::swap(_M_word, __rhs._M_word);
+       else
+        {
+          ios_base* __local;
+          ios_base* __allocated;
+          if (__lhs_local)
+            {
+              __local = this;
+              __allocated = &__rhs;
+            }
+          else
+            {
+              __local = &__rhs;
+              __allocated= this;
+            }
+          for (int __i = 0; __i < _S_local_word_size; __i++)
+            __allocated->_M_local_word[__i] = __local->_M_local_word[__i];
+          __local->_M_word = __allocated->_M_word;
+          __allocated->_M_word = __allocated->_M_local_word;
+        }
+       std::swap(_M_word_size, __rhs._M_word_size);
+     }
+    std::swap(_M_ios_locale, __rhs._M_ios_locale);
+  }
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
index 9cebe1e702034a980e4ca48535f75bcadf11550a..6da69f8ef2e30009b32ea8c1e0ec8e122b19bfac 100644 (file)
@@ -87,14 +87,8 @@ inst_sources = \
        allocator-inst.cc \
        concept-inst.cc \
        ext-inst.cc \
-       ios-inst.cc \
-       iostream-inst.cc \
-       istream-inst.cc \
        locale-inst.cc \
        misc-inst.cc \
-       ostream-inst.cc \
-       sstream-inst.cc \
-       streambuf-inst.cc \
        wlocale-inst.cc
 else
 # XTEMPLATE_FLAGS =
@@ -114,7 +108,6 @@ sources = \
        globals_io.cc \
        hash_tr1.cc \
        hashtable_tr1.cc \
-       ios.cc \
        ios_failure.cc \
        ios_init.cc \
        ios_locale.cc \
index cf9cda5f4d6d564a8d0b0c667fe1038994744730..38f96ccc943bfc0612aa16679eec5176894ce822 100644 (file)
@@ -72,23 +72,19 @@ am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \
        monetary_members.lo numeric_members.lo time_members.lo
 @ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_2 = allocator-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  concept-inst.lo ext-inst.lo \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  ios-inst.lo iostream-inst.lo \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  istream-inst.lo locale-inst.lo \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  misc-inst.lo ostream-inst.lo \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  sstream-inst.lo streambuf-inst.lo \
+@ENABLE_EXTERN_TEMPLATE_TRUE@  locale-inst.lo misc-inst.lo \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  wlocale-inst.lo
 am__objects_3 = parallel_settings.lo
 am__objects_4 = basic_file.lo c++locale.lo $(am__objects_2) \
        $(am__objects_3)
 am__objects_5 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
        codecvt.lo complex_io.lo ctype.lo globals_io.lo hash_tr1.lo \
-       hashtable_tr1.lo ios.lo ios_failure.lo ios_init.lo \
-       ios_locale.lo list.lo list-aux.lo list-aux-2.lo \
-       list_associated.lo list_associated-2.lo locale.lo \
-       locale_init.lo locale_facets.lo localename.lo \
-       math_stubs_float.lo math_stubs_long_double.lo stdexcept.lo \
-       strstream.lo tree.lo istream.lo streambuf.lo valarray.lo \
-       $(am__objects_1) $(am__objects_4)
+       hashtable_tr1.lo ios_failure.lo ios_init.lo ios_locale.lo \
+       list.lo list-aux.lo list-aux-2.lo list_associated.lo \
+       list_associated-2.lo locale.lo locale_init.lo locale_facets.lo \
+       localename.lo math_stubs_float.lo math_stubs_long_double.lo \
+       stdexcept.lo strstream.lo tree.lo istream.lo streambuf.lo \
+       valarray.lo $(am__objects_1) $(am__objects_4)
 am_libc__98convenience_la_OBJECTS = $(am__objects_5)
 libc__98convenience_la_OBJECTS = $(am_libc__98convenience_la_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -355,14 +351,8 @@ host_sources_extra = \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  allocator-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  concept-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  ext-inst.cc \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  ios-inst.cc \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  iostream-inst.cc \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  istream-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  locale-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  misc-inst.cc \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  ostream-inst.cc \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  sstream-inst.cc \
-@ENABLE_EXTERN_TEMPLATE_TRUE@  streambuf-inst.cc \
 @ENABLE_EXTERN_TEMPLATE_TRUE@  wlocale-inst.cc
 
 parallel_sources = parallel_settings.cc
@@ -378,7 +368,6 @@ sources = \
        globals_io.cc \
        hash_tr1.cc \
        hashtable_tr1.cc \
-       ios.cc \
        ios_failure.cc \
        ios_init.cc \
        ios_locale.cc \
index 0a78278589940992302c893636acd05bf07fa90f..f98f442cb9703d0e26ad99aae40bedd4bacb68dc 100644 (file)
@@ -27,7 +27,6 @@
 //
 
 #include <ext/rope>
-#include <ext/stdio_filebuf.h>
 
 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
@@ -47,8 +46,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     rope<char, std::allocator<char> >::
     _S_fetch(_Rope_RopeRep<char, std::allocator<char> >*, size_type);
 
-  template class stdio_filebuf<char>;
-
 #ifdef _GLIBCXX_USE_WCHAR_T
   template
     const unsigned long 
@@ -58,8 +55,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     wchar_t
     rope<wchar_t, std::allocator<wchar_t> >::
     _S_fetch(_Rope_RopeRep<wchar_t, std::allocator<wchar_t> >*, size_type);
-
-  template class stdio_filebuf<wchar_t>;
 #endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
index 1c414fcaeff2ea334bd811c210877a6d3606abac..540e76d468c9da016743cbc5212a91ca0d451052 100644 (file)
@@ -29,7 +29,6 @@
 #include <string>
 #include <istream>
 #include <ostream>
-#include <ext/stdio_sync_filebuf.h>
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -65,17 +64,3 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
-
-namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  template class stdio_sync_filebuf<char>;
-#ifdef _GLIBCXX_USE_WCHAR_T
-  template class stdio_sync_filebuf<wchar_t>;
-#endif
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace
-
-
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/cons/char/copy_neg.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/cons/char/copy_neg.cc
new file mode 100644 (file)
index 0000000..2080a9b
--- /dev/null
@@ -0,0 +1,28 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <fstream>
+
+void test()
+{
+  std::filebuf f;
+  std::filebuf ff(f); // { dg-error "deleted function" }
+  ff = f; // { dg-error "deleted function" }
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_fstream/assign/1.cc b/libstdc++-v3/testsuite/27_io/basic_fstream/assign/1.cc
new file mode 100644 (file)
index 0000000..84947d0
--- /dev/null
@@ -0,0 +1,88 @@
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-require-fileio "" }
+
+// 27.9.1.16 Assign and swap [fstream.assign]
+
+#include <fstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string const name = "fstream-assign.txt";
+
+void
+test01()
+{
+  string orig = "Let the whole outside world consist of a long paper tape.";
+  {
+    fstream f(name, ios::in|ios::out|ios::trunc);
+    VERIFY( f.is_open() );
+    f << orig;
+    fstream f1;
+    f1 = std::move(f);
+    VERIFY( f1.is_open() );
+    VERIFY( !f.is_open() );
+    f1.seekg(0);
+    string result;
+    getline(f1, result);
+    VERIFY( result == orig );
+  }
+  {
+    fstream f(name, ios::in);
+    VERIFY( f.is_open() );
+    fstream f1;
+    f1.swap(f);
+    VERIFY( f1.is_open() );
+    VERIFY( !f.is_open() );
+    string result;
+    getline(f1, result);
+    VERIFY( result == orig );
+  }
+  {
+    fstream f(name, ios::in);
+    VERIFY( f.is_open() );
+    fstream f1;
+    swap(f1, f);
+    VERIFY( f1.is_open() );
+    VERIFY( !f.is_open() );
+    string result;
+    getline(f1, result);
+    VERIFY( result == orig );
+  }
+}
+
+void
+test02()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  wfstream f, f2;
+  f2 = std::move(f);
+  f2.swap(f);
+  swap(f2, f);
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_fstream/cons/move.cc b/libstdc++-v3/testsuite/27_io/basic_fstream/cons/move.cc
new file mode 100644 (file)
index 0000000..1805e52
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-require-fileio "" }
+
+// 27.9.1.15 basic_fstream constructors [fstream.cons]
+
+#include <fstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+std::string const name = "fstream-move.txt";
+
+void
+test01()
+{
+  string orig = "Let the whole outside world consist of a long paper tape.";
+  fstream f(name, ios::in|ios::out|ios::trunc);
+  VERIFY( f.is_open() );
+  f << orig;
+  fstream f1 = std::move(f);
+  VERIFY( f1.is_open() );
+  VERIFY( !f.is_open() );
+  f1.seekg(0);
+  string result;
+  getline(f1, result);
+  VERIFY( result == orig );
+}
+
+void
+test02()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  wstring orig = L"Let the whole outside world consist of a long paper tape.";
+  wfstream f(name, ios::in|ios::out|ios::trunc);
+  VERIFY( f.is_open() );
+  f << orig;
+  wfstream f1 = std::move(f);
+  VERIFY( f1.is_open() );
+  VERIFY( !f.is_open() );
+  f1.seekg(0);
+  wstring result;
+  getline(f1, result);
+  VERIFY( result == orig );
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ifstream/assign/1.cc b/libstdc++-v3/testsuite/27_io/basic_ifstream/assign/1.cc
new file mode 100644 (file)
index 0000000..e652d47
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-require-fileio "" }
+
+// 27.9.1.8 Assign and swap [ifstream.assign]
+
+#include <fstream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+read(std::istream& in, std::ostream& out)
+{
+  std::string s;
+  for (int i=0; i < 10; ++i)
+  {
+    getline(in, s);
+    out << s << '\n';
+  }
+}
+
+void
+test01()
+{
+  std::string const name = "thirty_years_among_the_dead_preproc.txt";
+  std::ostringstream ss0;
+  {
+    std::ifstream f0(name);
+    read(f0, ss0);
+  }
+  {
+    std::ifstream f0(name);
+    std::ifstream f1;
+    f1 = std::move(f0);
+    VERIFY( !f0.is_open() );
+    VERIFY( f1.is_open() );
+    std::ostringstream ss1;
+    read(f1, ss1);
+    VERIFY( ss0.str() == ss1.str() );
+  }
+  {
+    std::ifstream f0(name);
+    std::ifstream f1;
+    f1.swap(f0);
+    VERIFY( !f0.is_open() );
+    VERIFY( f1.is_open() );
+    std::ostringstream ss1;
+    read(f1, ss1);
+    VERIFY( ss0.str() == ss1.str() );
+  }
+}
+
+void
+test02()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wifstream f, f2;
+  f2 = std::move(f);
+  f2.swap(f);
+  swap(f2, f);
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ifstream/cons/move.cc b/libstdc++-v3/testsuite/27_io/basic_ifstream/cons/move.cc
new file mode 100644 (file)
index 0000000..afa2a62
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-require-fileio "" }
+
+// 27.9.1.7 basic_ifstream constructors [ifstream.cons]
+
+#include <fstream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+read(std::istream& in, std::ostream& out)
+{
+  std::string s;
+  for (int i=0; i < 10; ++i)
+  {
+    getline(in, s);
+    out << s << '\n';
+  }
+}
+
+void
+test01()
+{
+  std::string const name = "thirty_years_among_the_dead_preproc.txt";
+  std::ostringstream ss0;
+  {
+    std::ifstream f0(name);
+    read(f0, ss0);
+  }
+  std::ifstream f0(name);
+  std::ifstream f1 = std::move(f0);
+  VERIFY( !f0.is_open() );
+  VERIFY( f1.is_open() );
+  std::ostringstream ss1;
+  read(f1, ss1);
+  VERIFY( ss0.str() == ss1.str() );
+}
+
+void
+test02()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wifstream f0("thirty_years_among_the_dead_preproc.txt");
+  std::wifstream f1 = std::move(f0);
+  VERIFY( f1.is_open() );
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/assign/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/assign/1.cc
new file mode 100644 (file)
index 0000000..a9ae2ae
--- /dev/null
@@ -0,0 +1,97 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.3.2 Assign and swap [istringstream.assign]
+
+#include <sstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  std::istringstream s1("absence of a signal");
+  std::string s;
+  s1 >> s;
+
+  std::istringstream s2;
+  s2 = std::move(s1);
+  s2 >> s;
+  VERIFY(s == "of");
+
+  std::istringstream s3;
+  s3.swap(s2);
+  s3 >> s;
+  VERIFY(s == "a");
+
+  swap(s1, s3);
+  s1 >> s;
+  VERIFY(s == "signal");
+
+  s2.str("should never be used as a signal");
+  s1 = std::move(s2);
+  getline(s1, s);
+  VERIFY(s == "should never be used as a signal");
+  s3 = std::move(s1);
+  VERIFY(s3.eof());
+}
+
+void test02()
+{
+  std::istringstream s0{ " 1234.5 " };
+  std::istringstream s;
+  s = std::move(s0);
+  char c{};
+  s >> c;
+  VERIFY( c == '1' );
+  int i{};
+  s >> i;
+  VERIFY( i == 234 );
+  double d{};
+  s >> d;
+  VERIFY( d == .5 );
+}
+
+void test03()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wistringstream s0{ L" 1234.5 " };
+  std::wistringstream s;
+  s = std::move(s0);
+  s.swap(s0);
+  swap(s, s0);
+  wchar_t c{};
+  s >> c;
+  VERIFY( c == L'1' );
+  int i{};
+  s >> i;
+  VERIFY( i == 234 );
+  double d{};
+  s >> d;
+  VERIFY( d == .5 );
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  test03();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/move.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/cons/move.cc
new file mode 100644 (file)
index 0000000..77c1fbb
--- /dev/null
@@ -0,0 +1,94 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.3.1 basic_istringstream constructors [istringstream.cons]
+
+#include <sstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  std::istringstream s1("absence of a signal");
+  std::string s;
+  s1 >> s;
+
+  std::istringstream s2 = std::move(s1);
+  s2 >> s;
+  VERIFY(s == "of");
+
+  std::istringstream s3;
+  s3 = std::move(s2);
+  s3 >> s;
+  VERIFY(s == "a");
+
+  s1 = std::move(s3);
+  s1 >> s;
+  VERIFY(s == "signal");
+
+  s2.str("should never be used as a signal");
+  s1 = std::move(s2);
+  getline(s1, s);
+  VERIFY(s == "should never be used as a signal");
+  s3 = std::move(s1);
+  VERIFY(s3.eof());
+}
+
+void
+test02()
+{
+  std::istringstream s0{ " 1234.5 " };
+  std::istringstream s{ std::move(s0) };
+  char c{};
+  s >> c;
+  VERIFY( c == '1' );
+  int i{};
+  s >> i;
+  VERIFY( i == 234 );
+  double d{};
+  s >> d;
+  VERIFY( d == .5 );
+}
+
+void
+test03()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wistringstream s0{ L" 1234.5 " };
+  std::wistringstream s{ std::move(s0) };
+  wchar_t c{};
+  s >> c;
+  VERIFY( c == L'1' );
+  int i{};
+  s >> i;
+  VERIFY( i == 234 );
+  double d{};
+  s >> d;
+  VERIFY( d == .5 );
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  test03();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/assign/1.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/assign/1.cc
new file mode 100644 (file)
index 0000000..7092ebe
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-require-fileio "" }
+
+// 27.9.1.12 Assign and swap [ostringstream.assign]
+
+#include <fstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string const name = "ofstream-assign.txt";
+
+void
+test01()
+{
+  string s1 = "Let the whole outside world";
+  string s2 = " consist of a long paper tape.";
+  ofstream f(name, ios::trunc);
+  VERIFY( f.is_open() );
+  f << s1;
+  {
+    ofstream f1;
+    f1 = std::move(f);
+    VERIFY( f1.is_open() );
+    VERIFY( !f.is_open() );
+    f1 << s2;
+    f1.swap(f);
+    VERIFY( !f1.is_open() );
+    VERIFY( f.is_open() );
+    f << s1;
+    swap(f1, f);
+    f1 << s2;
+  }
+  ifstream in(name);
+  string result;
+  getline(in, result);
+  VERIFY( result == (s1 + s2 + s1 + s2) );
+}
+
+void
+test02()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wofstream s0, s;
+  s = std::move(s0);
+  s.swap(s0);
+  swap(s, s0);
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/move.cc b/libstdc++-v3/testsuite/27_io/basic_ofstream/cons/move.cc
new file mode 100644 (file)
index 0000000..a6dca71
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-require-fileio "" }
+
+// 27.9.1.11 basic_ofstream constructors [ofstream.cons]
+
+#include <fstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+std::string const name = "ofstream-move.txt";
+
+void
+test01()
+{
+  string s1 = "Let the whole outside world";
+  string s2 = " consist of a long paper tape.";
+  ofstream f(name, ios::trunc);
+  VERIFY( f.is_open() );
+  f << s1;
+  {
+    ofstream f1 = std::move(f);
+    VERIFY( f1.is_open() );
+    VERIFY( !f.is_open() );
+    f1 << s2;
+  }
+  ifstream in(name);
+  string result;
+  getline(in, result);
+  VERIFY( result == (s1 + s2) );
+}
+
+void
+test02()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  wstring s1 = L"Let the whole outside world";
+  wstring s2 = L" consist of a long paper tape.";
+  wofstream f(name, ios::trunc);
+  VERIFY( f.is_open() );
+  f << s1;
+  {
+    wofstream f1 = std::move(f);
+    VERIFY( f1.is_open() );
+    VERIFY( !f.is_open() );
+    f1 << s2;
+  }
+  wifstream in(name);
+  wstring result;
+  getline(in, result);
+  VERIFY( result == (s1 + s2) );
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/assign/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/assign/1.cc
new file mode 100644 (file)
index 0000000..01b92e9
--- /dev/null
@@ -0,0 +1,117 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.4.2 Assign and swap [ostringstream.assign]
+
+#include <sstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+const std::string strings[] = {
+  "one could carry out the description of a machine, ",
+  "no matter how complicated, ",
+  "in characters which would be merely the letters of the alphabet, and so ",
+  "provide the mind with a method of knowing the machine and all its parts"
+};
+
+void
+append(std::ostringstream& ss, std::string& s, const std::string& t)
+{
+  ss << t;
+  s += t;
+}
+
+// assign
+void
+test01()
+{
+  std::string exp;
+  std::ostringstream s1;
+  append(s1, exp, strings[0]);
+
+  std::ostringstream s2;
+  s2 = std::move(s1);
+  VERIFY( s2.str() == exp );
+  append(s2, exp, strings[1]);
+  VERIFY( s2.str() == exp );
+
+  std::ostringstream s3;
+  s3 = std::move(s2);
+  VERIFY( s3.str() == exp );
+  append(s3, exp, strings[2]);
+  VERIFY( s3.str() == exp );
+
+  s1.setstate(std::ios::failbit);
+  s1 = std::move(s3);
+  VERIFY( s1.good() );
+  VERIFY( s1.str() == exp );
+  append(s1, exp, strings[3]);
+  VERIFY( s1.str() == exp );
+}
+
+// swap
+void
+test02()
+{
+  std::string exp;
+  std::ostringstream s1;
+  append(s1, exp, strings[0]);
+
+  std::ostringstream s2;
+  s2.swap(s1);
+  VERIFY( s1.str().empty() );
+  VERIFY( s2.str() == exp );
+  append(s2, exp, strings[1]);
+  VERIFY( s2.str() == exp );
+
+  std::ostringstream s3;
+  swap(s3, s2);
+  VERIFY( s2.str().empty() );
+  VERIFY( s3.str() == exp );
+  append(s3, exp, strings[2]);
+  VERIFY( s3.str() == exp );
+
+  s1.setstate(std::ios::failbit);
+  swap(s1, s3);
+  VERIFY( s1.good() );
+  VERIFY( s3.fail() );
+  VERIFY( s2.str().empty() );
+  VERIFY( s1.str() == exp );
+  append(s1, exp, strings[3]);
+  VERIFY( s1.str() == exp );
+}
+
+void
+test03()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wistringstream s0, s;
+  s = std::move(s0);
+  s.swap(s0);
+  swap(s, s0);
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  test03();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/move.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/move.cc
new file mode 100644 (file)
index 0000000..26ccf1a
--- /dev/null
@@ -0,0 +1,82 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.4.1 basic_ostringstream constructors [ostringstream.cons]
+
+#include <sstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+const std::string strings[] = {
+  "one could carry out the description of a machine, ",
+  "no matter how complicated, ",
+  "in characters which would be merely the letters of the alphabet, and so ",
+  "provide the mind with a method of knowing the machine and all its parts"
+};
+
+void
+append(std::ostringstream& ss, std::string& s, const std::string& t)
+{
+  ss << t;
+  s += t;
+}
+
+void
+test01()
+{
+  std::string exp;
+  std::ostringstream s1;
+  append(s1, exp, strings[0]);
+
+  std::ostringstream s2 = std::move(s1);
+  VERIFY( s2.good() );
+  VERIFY( s2.rdbuf() != nullptr );
+  VERIFY( s2.str() == exp );
+  append(s2, exp, strings[1]);
+  VERIFY( s2.str() == exp );
+
+  std::ostringstream s3 = std::move(s2);
+  VERIFY( s3.good() );
+  VERIFY( s3.rdbuf() != nullptr );
+  VERIFY( s3.str() == exp );
+  append(s3, exp, strings[2]);
+  VERIFY( s3.str() == exp );
+
+  s1.str("");
+  s1.clear();
+  exp.clear();
+  append(s1, exp, strings[3]);
+  VERIFY( s1.str() == exp );
+}
+
+void
+test02()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wostringstream s1;
+  std::wostringstream s2 = std::move(s1);
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/assign/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/assign/1.cc
new file mode 100644 (file)
index 0000000..0465461
--- /dev/null
@@ -0,0 +1,100 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.5.2 Assign and swap [stringstream.assign]
+
+#include <sstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  std::stringstream s1;
+  s1 << "absence of a signal";
+  std::string s;
+  s1 >> s;
+
+  std::stringstream s2;
+  s2 = std::move(s1);
+  s2 >> s;
+  VERIFY(s == "of");
+
+  std::stringstream s3;
+  s3.swap(s2);
+  s3 >> s;
+  VERIFY(s == "a");
+
+  swap(s1, s3);
+  s1 >> s;
+  VERIFY(s == "signal");
+
+  s2 << "should never be used as a signal";
+  s1 = std::move(s2);
+  getline(s1, s);
+  VERIFY(s == "should never be used as a signal");
+  s3 = std::move(s1);
+  VERIFY(s3.eof());
+}
+
+void test02()
+{
+  std::stringstream s0;
+  s0 << " 1234.5 ";
+  std::stringstream s;
+  s = std::move(s0);
+  char c{};
+  s >> c;
+  VERIFY( c == '1' );
+  int i{};
+  s >> i;
+  VERIFY( i == 234 );
+  double d{};
+  s >> d;
+  VERIFY( d == .5 );
+}
+
+void test03()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wstringstream s0;
+  s0 << L" 1234.5 ";
+  std::wstringstream s;
+  s = std::move(s0);
+  s.swap(s0);
+  swap(s, s0);
+  wchar_t c{};
+  s >> c;
+  VERIFY( c == L'1' );
+  int i{};
+  s >> i;
+  VERIFY( i == 234 );
+  double d{};
+  s >> d;
+  VERIFY( d == .5 );
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  test03();
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/move.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/cons/move.cc
new file mode 100644 (file)
index 0000000..3991e7c
--- /dev/null
@@ -0,0 +1,82 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.8.5.1 basic_stringstream constructors [stringstream.cons]
+
+#include <sstream>
+#include <string>
+#include <testsuite_hooks.h>
+
+const std::string strings[] = {
+  "one could carry out the description of a machine, ",
+  "no matter how complicated, ",
+  "in characters which would be merely the letters of the alphabet, and so ",
+  "provide the mind with a method of knowing the machine and all its parts"
+};
+
+void
+append(std::stringstream& ss, std::string& s, const std::string& t)
+{
+  ss << t;
+  s += t;
+}
+
+void
+test01()
+{
+  std::string exp;
+  std::stringstream s1;
+  append(s1, exp, strings[0]);
+
+  std::stringstream s2 = std::move(s1);
+  VERIFY( s2.good() );
+  VERIFY( s2.rdbuf() != nullptr );
+  VERIFY( s2.str() == exp );
+  append(s2, exp, strings[1]);
+  VERIFY( s2.str() == exp );
+
+  std::stringstream s3 = std::move(s2);
+  VERIFY( s3.good() );
+  VERIFY( s3.rdbuf() != nullptr );
+  VERIFY( s3.str() == exp );
+  append(s3, exp, strings[2]);
+  VERIFY( s3.str() == exp );
+
+  s1.str("");
+  s1.clear();
+  exp.clear();
+  append(s1, exp, strings[3]);
+  VERIFY( s1.str() == exp );
+}
+
+void
+test02()
+{
+#ifdef _GLIBCXX_USE_WCHAR_T
+  std::wstringstream s1;
+  std::wstringstream s2 = std::move(s1);
+#endif
+}
+
+int
+main()
+{
+  test01();
+  test02();
+}