diff mbox

Implement move semantics for iostreams

Message ID 20140922133507.GF22778@redhat.com
State New
Headers show

Commit Message

Jonathan Wakely Sept. 22, 2014, 1:35 p.m. UTC
This adds move and swap functions to the iostream classes.

Although this is a pretty large patch, it's a pure addition that only
affects C++11 mode, and should have no effect on existing code because
it won't be moving or swapping streams.

I wanted to use C++14's std::exchange so I added std::__exchange to
<bits/move.h> and made std::exchange forward to that.

I needed to add a new constructor to basic_ostream that doesn't call
init(0), for basic_iostream's move constructor to use.  (I wonder why
our non-standard default constructors for basic_istream and
basic_ostream call init(nullptr), rather than doing nothing.  Derived
classes that want init(nullptr) to be called can do that by passing
nullptr to the standard basic_istream and basic_ostream constructors
taking a pointer, which would allow the default constructors to be
re-purposed to intentionally leave the object uninitialized).

To ensure that the explicit instantiations in the library include the
new functions I had to move several files from src/c++98 to src/c++11,
which makes the patch huge, so the new tests are in a separate,
gzipped file to keep this post below the mailing list size limits.

Tested x86_64-linux, committed to trunk.

Comments

Andreas Schwab Sept. 23, 2014, 9:48 a.m. UTC | #1
Jonathan Wakely <jwakely@redhat.com> writes:

> Although this is a pretty large patch, it's a pure addition that only
> affects C++11 mode, and should have no effect on existing code because
> it won't be moving or swapping streams.

FAIL: g++.old-deja/g++.law/ctors10.C  -std=c++11 (test for excess errors)
Excess errors:
/daten/aranym/gcc/gcc-20140923/gcc/testsuite/g++.old-deja/g++.law/ctors10.C:16:46: error: call of overloaded 'basic_ostream(NULL)' is ambiguous

Andreas.
Jonathan Wakely Sept. 23, 2014, 9:58 a.m. UTC | #2
On 23/09/14 11:48 +0200, Andreas Schwab wrote:
>Jonathan Wakely <jwakely@redhat.com> writes:
>
>> Although this is a pretty large patch, it's a pure addition that only
>> affects C++11 mode, and should have no effect on existing code because
>> it won't be moving or swapping streams.
>
>FAIL: g++.old-deja/g++.law/ctors10.C  -std=c++11 (test for excess errors)
>Excess errors:
>/daten/aranym/gcc/gcc-20140923/gcc/testsuite/g++.old-deja/g++.law/ctors10.C:16:46: error: call of overloaded 'basic_ostream(NULL)' is ambiguous

Thanks, I'll adjust the new constructor.
Rainer Orth Sept. 23, 2014, 1:58 p.m. UTC | #3
Jonathan Wakely <jwakely@redhat.com> writes:

> This adds move and swap functions to the iostream classes.
>
> Although this is a pretty large patch, it's a pure addition that only
> affects C++11 mode, and should have no effect on existing code because
> it won't be moving or swapping streams.
>
> I wanted to use C++14's std::exchange so I added std::__exchange to
> <bits/move.h> and made std::exchange forward to that.
>
> I needed to add a new constructor to basic_ostream that doesn't call
> init(0), for basic_iostream's move constructor to use.  (I wonder why
> our non-standard default constructors for basic_istream and
> basic_ostream call init(nullptr), rather than doing nothing.  Derived
> classes that want init(nullptr) to be called can do that by passing
> nullptr to the standard basic_istream and basic_ostream constructors
> taking a pointer, which would allow the default constructors to be
> re-purposed to intentionally leave the object uninitialized).
>
> To ensure that the explicit instantiations in the library include the
> new functions I had to move several files from src/c++98 to src/c++11,
> which makes the patch huge, so the new tests are in a separate,
> gzipped file to keep this post below the mailing list size limits.
>
> Tested x86_64-linux, committed to trunk.

This patch broke Solaris bootstrap with Sun ld: when linking
libstdc++.so, ld complains

ld: fatal: libstdc++-symbols.ver-sun: 4520: symbol 'std::basic_ios<char, std::char_traits<char> >::move(std::basic_ios<char, std::char_traits<char> >&&)': symbol version conflict

and many more.  In that case, I find that this symbols is matched by
both the GLIBCXX_3.4 and GLIBCXX_3.4.21 patterns:

    GLIBCXX_3.4
    ##std::basic_i[g-r]* (cxx)
    _ZNSt9basic_iosIcSt11char_traitsIcEE4moveEOS2_;

    GLIBCXX_3.4.21
    ##_ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE4moveE[OR]S2_ (glob)
    _ZNSt9basic_iosIcSt11char_traitsIcEE4moveEOS2_;

	Rainer
Jonathan Wakely Sept. 23, 2014, 2:20 p.m. UTC | #4
On 23/09/14 15:58 +0200, Rainer Orth wrote:
>This patch broke Solaris bootstrap with Sun ld: when linking
>libstdc++.so, ld complains
>
>ld: fatal: libstdc++-symbols.ver-sun: 4520: symbol 'std::basic_ios<char, std::char_traits<char> >::move(std::basic_ios<char, std::char_traits<char> >&&)': symbol version conflict
>
>and many more.  In that case, I find that this symbols is matched by
>both the GLIBCXX_3.4 and GLIBCXX_3.4.21 patterns:
>
>    GLIBCXX_3.4
>    ##std::basic_i[g-r]* (cxx)
>    _ZNSt9basic_iosIcSt11char_traitsIcEE4moveEOS2_;
>
>    GLIBCXX_3.4.21
>    ##_ZNSt9basic_iosI[cw]St11char_traitsI[cw]EE4moveE[OR]S2_ (glob)
>    _ZNSt9basic_iosIcSt11char_traitsIcEE4moveEOS2_;

Drat, I did notice those patterns were too greedy, as my new symbols
got the wrong version until I added patterns for them. I didn't
realise it would break Solaris.

I'll work on refining the GLIBCXX_3.4 patterns to be more precise.
diff mbox

Patch

commit ac4314b3a2451147601385e26f19bb95b84c69d0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Sep 12 19:56:06 2014 +0100

    Make streams movable and swappable.
    
    	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.

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 41fac71..669e36d 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -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;
 
 
diff --git a/libstdc++-v3/config/io/basic_file_stdio.h b/libstdc++-v3/config/io/basic_file_stdio.h
index b457ec5..f58164e 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.h
+++ b/libstdc++-v3/config/io/basic_file_stdio.h
@@ -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);
 
diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/include/bits/basic_ios.h
index 58bede4..10263ed 100644
--- a/libstdc++-v3/include/bits/basic_ios.h
+++ b/libstdc++-v3/include/bits/basic_ios.h
@@ -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);
     };
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 21a67cd..b0404ea 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -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>::
diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h
index 4aade68..fb448fd 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -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
   };
 
diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h
index dc4ac0f..2fd0d37 100644
--- a/libstdc++-v3/include/bits/move.h
+++ b/libstdc++-v3/include/bits/move.h
@@ -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
diff --git a/libstdc++-v3/include/ext/stdio_filebuf.h b/libstdc++-v3/include/ext/stdio_filebuf.h
index 2874163..8d01690 100644
--- a/libstdc++-v3/include/ext/stdio_filebuf.h
+++ b/libstdc++-v3/include/ext/stdio_filebuf.h
@@ -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.
        *
diff --git a/libstdc++-v3/include/ext/stdio_sync_filebuf.h b/libstdc++-v3/include/ext/stdio_sync_filebuf.h
index 73283a7..c881172 100644
--- a/libstdc++-v3/include/ext/stdio_sync_filebuf.h
+++ b/libstdc++-v3/include/ext/stdio_sync_filebuf.h
@@ -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*.
        *
diff --git a/libstdc++-v3/include/std/fstream b/libstdc++-v3/include/std/fstream
index 4d802f1..fcf5f94 100644
--- a/libstdc++-v3/include/std/fstream
+++ b/libstdc++-v3/include/std/fstream
@@ -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
 
diff --git a/libstdc++-v3/include/std/ios b/libstdc++-v3/include/std/ios
index 5d69c4b..acfd7c2 100644
--- a/libstdc++-v3/include/std/ios
+++ b/libstdc++-v3/include/std/ios
@@ -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 */
diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream
index f063768..3a47616 100644
--- a/libstdc++-v3/include/std/istream
+++ b/libstdc++-v3/include/std/istream
@@ -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
     };
 
   /**
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index a25b3d0..748b805 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -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);
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index f97caba..f074eda 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -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
 
diff --git a/libstdc++-v3/include/std/streambuf b/libstdc++-v3/include/std/streambuf
index d3aa0ee..fce165f 100644
--- a/libstdc++-v3/include/std/streambuf
+++ b/libstdc++-v3/include/std/streambuf
@@ -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
diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility
index 6d12839e..cb7e112 100644
--- a/libstdc++-v3/include/std/utility
+++ b/libstdc++-v3/include/std/utility
@@ -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
diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am
index cf1e3be..39425d4 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -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
diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in
index 83b7bd1..70c6c4b 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -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
index 0000000..5d4f95b
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ext11-inst.cc
@@ -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
diff --git a/libstdc++-v3/src/c++11/ios-inst.cc b/libstdc++-v3/src/c++11/ios-inst.cc
new file mode 100644
index 0000000..979c252
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ios-inst.cc
@@ -0,0 +1,42 @@ 
+// Explicit instantiation file.
+
+// Copyright (C) 1997-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/>.
+
+//
+// ISO C++ 14882:
+//
+
+#include <ios>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  template class basic_ios<char>;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  template class basic_ios<wchar_t>;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc
new file mode 100644
index 0000000..b5124ec
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ios.cc
@@ -0,0 +1,259 @@ 
+// Iostreams base classes -*- C++ -*-
+
+// Copyright (C) 1997-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/>.
+
+//
+// ISO C++ 14882: 27.4  Iostreams base classes
+//
+
+#include <ios>
+#include <limits>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  // Definitions for static const members of ios_base.
+  const ios_base::fmtflags ios_base::boolalpha;
+  const ios_base::fmtflags ios_base::dec;
+  const ios_base::fmtflags ios_base::fixed;
+  const ios_base::fmtflags ios_base::hex;
+  const ios_base::fmtflags ios_base::internal;
+  const ios_base::fmtflags ios_base::left;
+  const ios_base::fmtflags ios_base::oct;
+  const ios_base::fmtflags ios_base::right;
+  const ios_base::fmtflags ios_base::scientific;
+  const ios_base::fmtflags ios_base::showbase;
+  const ios_base::fmtflags ios_base::showpoint;
+  const ios_base::fmtflags ios_base::showpos;
+  const ios_base::fmtflags ios_base::skipws;
+  const ios_base::fmtflags ios_base::unitbuf;
+  const ios_base::fmtflags ios_base::uppercase;
+  const ios_base::fmtflags ios_base::adjustfield;
+  const ios_base::fmtflags ios_base::basefield;
+  const ios_base::fmtflags ios_base::floatfield;
+
+  const ios_base::iostate ios_base::badbit;
+  const ios_base::iostate ios_base::eofbit;
+  const ios_base::iostate ios_base::failbit;
+  const ios_base::iostate ios_base::goodbit;
+
+  const ios_base::openmode ios_base::app;
+  const ios_base::openmode ios_base::ate;
+  const ios_base::openmode ios_base::binary;
+  const ios_base::openmode ios_base::in;
+  const ios_base::openmode ios_base::out;
+  const ios_base::openmode ios_base::trunc;
+
+  const ios_base::seekdir ios_base::beg;
+  const ios_base::seekdir ios_base::cur;
+  const ios_base::seekdir ios_base::end;
+
+  _Atomic_word ios_base::Init::_S_refcount;
+
+  bool ios_base::Init::_S_synced_with_stdio = true;
+
+  ios_base::ios_base() throw()
+  : _M_precision(), _M_width(), _M_flags(), _M_exception(), 
+  _M_streambuf_state(), _M_callbacks(0), _M_word_zero(), 
+  _M_word_size(_S_local_word_size), _M_word(_M_local_word), _M_ios_locale()
+  {
+    // Do nothing: basic_ios::init() does it.  
+    // NB: _M_callbacks and _M_word must be zero for non-initialized
+    // ios_base to go through ~ios_base gracefully.
+  }
+  
+  // 27.4.2.7  ios_base constructors/destructors
+  ios_base::~ios_base()
+  {
+    _M_call_callbacks(erase_event);
+    _M_dispose_callbacks();
+    if (_M_word != _M_local_word) 
+      {
+	delete [] _M_word;
+	_M_word = 0;
+      }
+  }
+
+  // 27.4.2.5  ios_base storage functions
+  int 
+  ios_base::xalloc() throw()
+  {
+    // Implementation note: Initialize top to zero to ensure that
+    // initialization occurs before main() is started.
+    static _Atomic_word _S_top = 0; 
+    return __gnu_cxx::__exchange_and_add_dispatch(&_S_top, 1) + 4;
+  }
+
+  void 
+  ios_base::register_callback(event_callback __fn, int __index)
+  { _M_callbacks = new _Callback_list(__fn, __index, _M_callbacks); }
+
+  // 27.4.2.5  iword/pword storage
+  ios_base::_Words&
+  ios_base::_M_grow_words(int __ix, bool __iword)
+  {
+    // Precondition: _M_word_size <= __ix
+    int __newsize = _S_local_word_size;
+    _Words* __words = _M_local_word;
+    if (__ix > _S_local_word_size - 1)
+      {
+	if (__ix < numeric_limits<int>::max())
+	  {
+	    __newsize = __ix + 1;
+	    __try
+	      { __words = new _Words[__newsize]; }
+	    __catch(const std::bad_alloc&)
+	      {
+		_M_streambuf_state |= badbit;
+		if (_M_streambuf_state & _M_exception)
+		  __throw_ios_failure(__N("ios_base::_M_grow_words "
+					  "allocation failed"));
+		if (__iword)
+		  _M_word_zero._M_iword = 0;
+		else
+		  _M_word_zero._M_pword = 0;
+		return _M_word_zero;
+	      }
+	    for (int __i = 0; __i < _M_word_size; __i++) 
+	      __words[__i] = _M_word[__i];
+	    if (_M_word && _M_word != _M_local_word) 
+	      {
+		delete [] _M_word;
+		_M_word = 0;
+	      }
+	  }
+	else
+	  {
+	    _M_streambuf_state |= badbit;
+	    if (_M_streambuf_state & _M_exception)
+	      __throw_ios_failure(__N("ios_base::_M_grow_words is not valid"));
+	    if (__iword)
+	      _M_word_zero._M_iword = 0;
+	    else
+	      _M_word_zero._M_pword = 0;
+	    return _M_word_zero;
+	  }
+      }
+    _M_word = __words;
+    _M_word_size = __newsize;
+    return _M_word[__ix];
+  }
+
+  void 
+  ios_base::_M_call_callbacks(event __e) throw()
+  {
+    _Callback_list* __p = _M_callbacks;
+    while (__p)
+      {
+	__try 
+	  { (*__p->_M_fn) (__e, *this, __p->_M_index); } 
+	__catch(...) 
+	  { }
+	__p = __p->_M_next;
+      }
+  }
+
+  void 
+  ios_base::_M_dispose_callbacks(void) throw()
+  {
+    _Callback_list* __p = _M_callbacks;
+    while (__p && __p->_M_remove_reference() == 0)
+      {
+	_Callback_list* __next = __p->_M_next;
+	delete __p;
+	__p = __next;
+      }
+    _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
diff --git a/libstdc++-v3/src/c++11/iostream-inst.cc b/libstdc++-v3/src/c++11/iostream-inst.cc
new file mode 100644
index 0000000..149d9c2
--- /dev/null
+++ b/libstdc++-v3/src/c++11/iostream-inst.cc
@@ -0,0 +1,47 @@ 
+// Explicit instantiation file.
+
+// Copyright (C) 1997-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/>.
+
+//
+// ISO C++ 14882:
+//
+
+#include <iomanip>
+#include <istream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  template class _Setfill<char>;
+  template _Setfill<char> setfill(char);
+  template class basic_iostream<char>;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  template class _Setfill<wchar_t>;
+  template _Setfill<wchar_t> setfill(wchar_t);
+  template class basic_iostream<wchar_t>; 
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/istream-inst.cc b/libstdc++-v3/src/c++11/istream-inst.cc
new file mode 100644
index 0000000..dc8832d
--- /dev/null
+++ b/libstdc++-v3/src/c++11/istream-inst.cc
@@ -0,0 +1,114 @@ 
+// Explicit instantiation file.
+
+// Copyright (C) 1997-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/>.
+
+//
+// ISO C++ 14882:
+//
+
+#include <istream>
+#include <iomanip>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  template class basic_istream<char>;
+  template istream& ws(istream&);
+  template istream& operator>>(istream&, char&);
+  template istream& operator>>(istream&, unsigned char&);
+  template istream& operator>>(istream&, signed char&);
+  template istream& operator>>(istream&, char*);
+  template istream& operator>>(istream&, unsigned char*);
+  template istream& operator>>(istream&, signed char*);
+
+  template istream& operator>>(istream&, _Setfill<char>);
+  template istream& operator>>(istream&, _Setiosflags);
+  template istream& operator>>(istream&, _Resetiosflags);
+  template istream& operator>>(istream&, _Setbase);
+  template istream& operator>>(istream&, _Setprecision);
+  template istream& operator>>(istream&, _Setw);
+
+  template istream& istream::_M_extract(unsigned short&);
+  template istream& istream::_M_extract(unsigned int&);  
+  template istream& istream::_M_extract(long&);
+  template istream& istream::_M_extract(unsigned long&);
+  template istream& istream::_M_extract(bool&);
+#ifdef _GLIBCXX_USE_LONG_LONG
+  template istream& istream::_M_extract(long long&);
+  template istream& istream::_M_extract(unsigned long long&);
+#endif
+  template istream& istream::_M_extract(float&);
+  template istream& istream::_M_extract(double&);
+  template istream& istream::_M_extract(long double&);
+  template istream& istream::_M_extract(void*&);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  template class basic_istream<wchar_t>;
+  template wistream& ws(wistream&);
+  template wistream& operator>>(wistream&, wchar_t&);
+  template wistream& operator>>(wistream&, wchar_t*);
+
+  template wistream& operator>>(wistream&, _Setfill<wchar_t>);
+  template wistream& operator>>(wistream&, _Setiosflags);
+  template wistream& operator>>(wistream&, _Resetiosflags);
+  template wistream& operator>>(wistream&, _Setbase);
+  template wistream& operator>>(wistream&, _Setprecision);
+  template wistream& operator>>(wistream&, _Setw);
+
+  template wistream& wistream::_M_extract(unsigned short&);
+  template wistream& wistream::_M_extract(unsigned int&);  
+  template wistream& wistream::_M_extract(long&);
+  template wistream& wistream::_M_extract(unsigned long&);
+  template wistream& wistream::_M_extract(bool&);
+#ifdef _GLIBCXX_USE_LONG_LONG
+  template wistream& wistream::_M_extract(long long&);
+  template wistream& wistream::_M_extract(unsigned long long&);
+#endif
+  template wistream& wistream::_M_extract(float&);
+  template wistream& wistream::_M_extract(double&);
+  template wistream& wistream::_M_extract(long double&);
+  template wistream& wistream::_M_extract(void*&);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+// XXX GLIBCXX_ABI Deprecated
+#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
+
+#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
+  extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
+_GLIBCXX_LDBL_COMPAT (_ZNSirsERd, _ZNSirsERe);
+#ifdef _GLIBCXX_USE_WCHAR_T
+_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_istreamIwSt11char_traitsIwEErsERd,
+		      _ZNSt13basic_istreamIwSt11char_traitsIwEErsERe);
+#endif
+_GLIBCXX_LDBL_COMPAT (_ZNSi10_M_extractIdEERSiRT_,
+		      _ZNSi10_M_extractIeEERSiRT_);
+#ifdef _GLIBCXX_USE_WCHAR_T
+_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractIdEERS2_RT_,
+		      _ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractIeEERS2_RT_);
+#endif
+
+#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
diff --git a/libstdc++-v3/src/c++11/ostream-inst.cc b/libstdc++-v3/src/c++11/ostream-inst.cc
new file mode 100644
index 0000000..5e8eab1
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ostream-inst.cc
@@ -0,0 +1,117 @@ 
+// Explicit instantiation file.
+
+// Copyright (C) 1997-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/>.
+
+//
+// ISO C++ 14882:
+//
+
+#include <ostream>
+#include <iomanip>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  // ostream
+  template class basic_ostream<char>;
+  template ostream& endl(ostream&);
+  template ostream& ends(ostream&);
+  template ostream& flush(ostream&);
+  template ostream& operator<<(ostream&, char);
+  template ostream& operator<<(ostream&, unsigned char);
+  template ostream& operator<<(ostream&, signed char);
+  template ostream& operator<<(ostream&, const char*);
+  template ostream& operator<<(ostream&, const unsigned char*);
+  template ostream& operator<<(ostream&, const signed char*);
+
+  template ostream& operator<<(ostream&, _Setfill<char>);
+  template ostream& operator<<(ostream&, _Setiosflags);
+  template ostream& operator<<(ostream&, _Resetiosflags);
+  template ostream& operator<<(ostream&, _Setbase);
+  template ostream& operator<<(ostream&, _Setprecision);
+  template ostream& operator<<(ostream&, _Setw);
+  template ostream& __ostream_insert(ostream&, const char*, streamsize);
+
+  template ostream& ostream::_M_insert(long);
+  template ostream& ostream::_M_insert(unsigned long);
+  template ostream& ostream::_M_insert(bool);
+#ifdef _GLIBCXX_USE_LONG_LONG
+  template ostream& ostream::_M_insert(long long);
+  template ostream& ostream::_M_insert(unsigned long long);
+#endif
+  template ostream& ostream::_M_insert(double);
+  template ostream& ostream::_M_insert(long double);
+  template ostream& ostream::_M_insert(const void*);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  template class basic_ostream<wchar_t>;
+  template wostream& endl(wostream&);
+  template wostream& ends(wostream&);
+  template wostream& flush(wostream&);
+  template wostream& operator<<(wostream&, wchar_t);
+  template wostream& operator<<(wostream&, char);
+  template wostream& operator<<(wostream&, const wchar_t*);
+  template wostream& operator<<(wostream&, const char*);
+
+  template wostream& operator<<(wostream&, _Setfill<wchar_t>);
+  template wostream& operator<<(wostream&, _Setiosflags);
+  template wostream& operator<<(wostream&, _Resetiosflags);
+  template wostream& operator<<(wostream&, _Setbase);
+  template wostream& operator<<(wostream&, _Setprecision);
+  template wostream& operator<<(wostream&, _Setw);
+  template wostream& __ostream_insert(wostream&, const wchar_t*, streamsize);
+
+  template wostream& wostream::_M_insert(long);
+  template wostream& wostream::_M_insert(unsigned long);
+  template wostream& wostream::_M_insert(bool);
+#ifdef _GLIBCXX_USE_LONG_LONG
+  template wostream& wostream::_M_insert(long long);
+  template wostream& wostream::_M_insert(unsigned long long);
+#endif
+  template wostream& wostream::_M_insert(double);
+  template wostream& wostream::_M_insert(long double);
+  template wostream& wostream::_M_insert(const void*);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+// XXX GLIBCXX_ABI Deprecated
+#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
+
+#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
+  extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
+_GLIBCXX_LDBL_COMPAT (_ZNSolsEd, _ZNSolsEe);
+#ifdef _GLIBCXX_USE_WCHAR_T
+_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEd,
+		      _ZNSt13basic_ostreamIwSt11char_traitsIwEElsEe);
+#endif
+_GLIBCXX_LDBL_COMPAT (_ZNSo9_M_insertIdEERSoT_,
+		      _ZNSo9_M_insertIeEERSoT_);
+#ifdef _GLIBCXX_USE_WCHAR_T
+_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_,
+		      _ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIeEERS2_T_);
+#endif
+
+#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
diff --git a/libstdc++-v3/src/c++11/sstream-inst.cc b/libstdc++-v3/src/c++11/sstream-inst.cc
new file mode 100644
index 0000000..728946e
--- /dev/null
+++ b/libstdc++-v3/src/c++11/sstream-inst.cc
@@ -0,0 +1,48 @@ 
+// Explicit instantiation file.
+
+// Copyright (C) 1997-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/>.
+
+//
+// ISO C++ 14882:
+//
+
+#include <sstream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  template class basic_stringbuf<char>;
+  template class basic_istringstream<char>;
+  template class basic_ostringstream<char>;
+  template class basic_stringstream<char>;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  template class basic_stringbuf<wchar_t>;
+  template class basic_istringstream<wchar_t>; 
+  template class basic_ostringstream<wchar_t>; 
+  template class basic_stringstream<wchar_t>; 
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/streambuf-inst.cc b/libstdc++-v3/src/c++11/streambuf-inst.cc
new file mode 100644
index 0000000..e79d627
--- /dev/null
+++ b/libstdc++-v3/src/c++11/streambuf-inst.cc
@@ -0,0 +1,63 @@ 
+// Explicit instantiation file.
+
+// Copyright (C) 1997-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/>.
+
+//
+// ISO C++ 14882:
+//
+
+#include <ios>
+#include <streambuf>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  // streambuf
+  template class basic_streambuf<char>;
+
+  template
+    streamsize
+    __copy_streambufs(basic_streambuf<char>*, basic_streambuf<char>*);
+
+  template
+    streamsize
+    __copy_streambufs_eof(basic_streambuf<char>*,
+			  basic_streambuf<char>*, bool&);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+  // wstreambuf
+  template class basic_streambuf<wchar_t>;
+
+  template
+    streamsize
+    __copy_streambufs(basic_streambuf<wchar_t>*, basic_streambuf<wchar_t>*);
+
+  template
+    streamsize
+    __copy_streambufs_eof(basic_streambuf<wchar_t>*,
+			  basic_streambuf<wchar_t>*, bool&);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++98/Makefile.am b/libstdc++-v3/src/c++98/Makefile.am
index 9cebe1e..6da69f8 100644
--- a/libstdc++-v3/src/c++98/Makefile.am
+++ b/libstdc++-v3/src/c++98/Makefile.am
@@ -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 \
diff --git a/libstdc++-v3/src/c++98/Makefile.in b/libstdc++-v3/src/c++98/Makefile.in
index cf9cda5..38f96cc 100644
--- a/libstdc++-v3/src/c++98/Makefile.in
+++ b/libstdc++-v3/src/c++98/Makefile.in
@@ -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 \
diff --git a/libstdc++-v3/src/c++98/ext-inst.cc b/libstdc++-v3/src/c++98/ext-inst.cc
index 0a78278..f98f442 100644
--- a/libstdc++-v3/src/c++98/ext-inst.cc
+++ b/libstdc++-v3/src/c++98/ext-inst.cc
@@ -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
diff --git a/libstdc++-v3/src/c++98/ios-inst.cc b/libstdc++-v3/src/c++98/ios-inst.cc
deleted file mode 100644
index 979c252..0000000
--- a/libstdc++-v3/src/c++98/ios-inst.cc
+++ /dev/null
@@ -1,42 +0,0 @@ 
-// Explicit instantiation file.
-
-// Copyright (C) 1997-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/>.
-
-//
-// ISO C++ 14882:
-//
-
-#include <ios>
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  template class basic_ios<char>;
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  template class basic_ios<wchar_t>;
-#endif
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace
diff --git a/libstdc++-v3/src/c++98/ios.cc b/libstdc++-v3/src/c++98/ios.cc
deleted file mode 100644
index b0fab28..0000000
--- a/libstdc++-v3/src/c++98/ios.cc
+++ /dev/null
@@ -1,191 +0,0 @@ 
-// Iostreams base classes -*- C++ -*-
-
-// Copyright (C) 1997-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/>.
-
-//
-// ISO C++ 14882: 27.4  Iostreams base classes
-//
-
-#include <ios>
-#include <limits>
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  // Definitions for static const members of ios_base.
-  const ios_base::fmtflags ios_base::boolalpha;
-  const ios_base::fmtflags ios_base::dec;
-  const ios_base::fmtflags ios_base::fixed;
-  const ios_base::fmtflags ios_base::hex;
-  const ios_base::fmtflags ios_base::internal;
-  const ios_base::fmtflags ios_base::left;
-  const ios_base::fmtflags ios_base::oct;
-  const ios_base::fmtflags ios_base::right;
-  const ios_base::fmtflags ios_base::scientific;
-  const ios_base::fmtflags ios_base::showbase;
-  const ios_base::fmtflags ios_base::showpoint;
-  const ios_base::fmtflags ios_base::showpos;
-  const ios_base::fmtflags ios_base::skipws;
-  const ios_base::fmtflags ios_base::unitbuf;
-  const ios_base::fmtflags ios_base::uppercase;
-  const ios_base::fmtflags ios_base::adjustfield;
-  const ios_base::fmtflags ios_base::basefield;
-  const ios_base::fmtflags ios_base::floatfield;
-
-  const ios_base::iostate ios_base::badbit;
-  const ios_base::iostate ios_base::eofbit;
-  const ios_base::iostate ios_base::failbit;
-  const ios_base::iostate ios_base::goodbit;
-
-  const ios_base::openmode ios_base::app;
-  const ios_base::openmode ios_base::ate;
-  const ios_base::openmode ios_base::binary;
-  const ios_base::openmode ios_base::in;
-  const ios_base::openmode ios_base::out;
-  const ios_base::openmode ios_base::trunc;
-
-  const ios_base::seekdir ios_base::beg;
-  const ios_base::seekdir ios_base::cur;
-  const ios_base::seekdir ios_base::end;
-
-  _Atomic_word ios_base::Init::_S_refcount;
-
-  bool ios_base::Init::_S_synced_with_stdio = true;
-
-  ios_base::ios_base() throw()
-  : _M_precision(), _M_width(), _M_flags(), _M_exception(), 
-  _M_streambuf_state(), _M_callbacks(0), _M_word_zero(), 
-  _M_word_size(_S_local_word_size), _M_word(_M_local_word), _M_ios_locale()
-  {
-    // Do nothing: basic_ios::init() does it.  
-    // NB: _M_callbacks and _M_word must be zero for non-initialized
-    // ios_base to go through ~ios_base gracefully.
-  }
-  
-  // 27.4.2.7  ios_base constructors/destructors
-  ios_base::~ios_base()
-  {
-    _M_call_callbacks(erase_event);
-    _M_dispose_callbacks();
-    if (_M_word != _M_local_word) 
-      {
-	delete [] _M_word;
-	_M_word = 0;
-      }
-  }
-
-  // 27.4.2.5  ios_base storage functions
-  int 
-  ios_base::xalloc() throw()
-  {
-    // Implementation note: Initialize top to zero to ensure that
-    // initialization occurs before main() is started.
-    static _Atomic_word _S_top = 0; 
-    return __gnu_cxx::__exchange_and_add_dispatch(&_S_top, 1) + 4;
-  }
-
-  void 
-  ios_base::register_callback(event_callback __fn, int __index)
-  { _M_callbacks = new _Callback_list(__fn, __index, _M_callbacks); }
-
-  // 27.4.2.5  iword/pword storage
-  ios_base::_Words&
-  ios_base::_M_grow_words(int __ix, bool __iword)
-  {
-    // Precondition: _M_word_size <= __ix
-    int __newsize = _S_local_word_size;
-    _Words* __words = _M_local_word;
-    if (__ix > _S_local_word_size - 1)
-      {
-	if (__ix < numeric_limits<int>::max())
-	  {
-	    __newsize = __ix + 1;
-	    __try
-	      { __words = new _Words[__newsize]; }
-	    __catch(const std::bad_alloc&)
-	      {
-		_M_streambuf_state |= badbit;
-		if (_M_streambuf_state & _M_exception)
-		  __throw_ios_failure(__N("ios_base::_M_grow_words "
-					  "allocation failed"));
-		if (__iword)
-		  _M_word_zero._M_iword = 0;
-		else
-		  _M_word_zero._M_pword = 0;
-		return _M_word_zero;
-	      }
-	    for (int __i = 0; __i < _M_word_size; __i++) 
-	      __words[__i] = _M_word[__i];
-	    if (_M_word && _M_word != _M_local_word) 
-	      {
-		delete [] _M_word;
-		_M_word = 0;
-	      }
-	  }
-	else
-	  {
-	    _M_streambuf_state |= badbit;
-	    if (_M_streambuf_state & _M_exception)
-	      __throw_ios_failure(__N("ios_base::_M_grow_words is not valid"));
-	    if (__iword)
-	      _M_word_zero._M_iword = 0;
-	    else
-	      _M_word_zero._M_pword = 0;
-	    return _M_word_zero;
-	  }
-      }
-    _M_word = __words;
-    _M_word_size = __newsize;
-    return _M_word[__ix];
-  }
-
-  void 
-  ios_base::_M_call_callbacks(event __e) throw()
-  {
-    _Callback_list* __p = _M_callbacks;
-    while (__p)
-      {
-	__try 
-	  { (*__p->_M_fn) (__e, *this, __p->_M_index); } 
-	__catch(...) 
-	  { }
-	__p = __p->_M_next;
-      }
-  }
-
-  void 
-  ios_base::_M_dispose_callbacks(void) throw()
-  {
-    _Callback_list* __p = _M_callbacks;
-    while (__p && __p->_M_remove_reference() == 0)
-      {
-	_Callback_list* __next = __p->_M_next;
-	delete __p;
-	__p = __next;
-      }
-    _M_callbacks = 0;
-  }
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace
diff --git a/libstdc++-v3/src/c++98/iostream-inst.cc b/libstdc++-v3/src/c++98/iostream-inst.cc
deleted file mode 100644
index 149d9c2..0000000
--- a/libstdc++-v3/src/c++98/iostream-inst.cc
+++ /dev/null
@@ -1,47 +0,0 @@ 
-// Explicit instantiation file.
-
-// Copyright (C) 1997-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/>.
-
-//
-// ISO C++ 14882:
-//
-
-#include <iomanip>
-#include <istream>
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  template class _Setfill<char>;
-  template _Setfill<char> setfill(char);
-  template class basic_iostream<char>;
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  template class _Setfill<wchar_t>;
-  template _Setfill<wchar_t> setfill(wchar_t);
-  template class basic_iostream<wchar_t>; 
-#endif
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace
diff --git a/libstdc++-v3/src/c++98/istream-inst.cc b/libstdc++-v3/src/c++98/istream-inst.cc
deleted file mode 100644
index dc8832d..0000000
--- a/libstdc++-v3/src/c++98/istream-inst.cc
+++ /dev/null
@@ -1,114 +0,0 @@ 
-// Explicit instantiation file.
-
-// Copyright (C) 1997-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/>.
-
-//
-// ISO C++ 14882:
-//
-
-#include <istream>
-#include <iomanip>
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  template class basic_istream<char>;
-  template istream& ws(istream&);
-  template istream& operator>>(istream&, char&);
-  template istream& operator>>(istream&, unsigned char&);
-  template istream& operator>>(istream&, signed char&);
-  template istream& operator>>(istream&, char*);
-  template istream& operator>>(istream&, unsigned char*);
-  template istream& operator>>(istream&, signed char*);
-
-  template istream& operator>>(istream&, _Setfill<char>);
-  template istream& operator>>(istream&, _Setiosflags);
-  template istream& operator>>(istream&, _Resetiosflags);
-  template istream& operator>>(istream&, _Setbase);
-  template istream& operator>>(istream&, _Setprecision);
-  template istream& operator>>(istream&, _Setw);
-
-  template istream& istream::_M_extract(unsigned short&);
-  template istream& istream::_M_extract(unsigned int&);  
-  template istream& istream::_M_extract(long&);
-  template istream& istream::_M_extract(unsigned long&);
-  template istream& istream::_M_extract(bool&);
-#ifdef _GLIBCXX_USE_LONG_LONG
-  template istream& istream::_M_extract(long long&);
-  template istream& istream::_M_extract(unsigned long long&);
-#endif
-  template istream& istream::_M_extract(float&);
-  template istream& istream::_M_extract(double&);
-  template istream& istream::_M_extract(long double&);
-  template istream& istream::_M_extract(void*&);
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  template class basic_istream<wchar_t>;
-  template wistream& ws(wistream&);
-  template wistream& operator>>(wistream&, wchar_t&);
-  template wistream& operator>>(wistream&, wchar_t*);
-
-  template wistream& operator>>(wistream&, _Setfill<wchar_t>);
-  template wistream& operator>>(wistream&, _Setiosflags);
-  template wistream& operator>>(wistream&, _Resetiosflags);
-  template wistream& operator>>(wistream&, _Setbase);
-  template wistream& operator>>(wistream&, _Setprecision);
-  template wistream& operator>>(wistream&, _Setw);
-
-  template wistream& wistream::_M_extract(unsigned short&);
-  template wistream& wistream::_M_extract(unsigned int&);  
-  template wistream& wistream::_M_extract(long&);
-  template wistream& wistream::_M_extract(unsigned long&);
-  template wistream& wistream::_M_extract(bool&);
-#ifdef _GLIBCXX_USE_LONG_LONG
-  template wistream& wistream::_M_extract(long long&);
-  template wistream& wistream::_M_extract(unsigned long long&);
-#endif
-  template wistream& wistream::_M_extract(float&);
-  template wistream& wistream::_M_extract(double&);
-  template wistream& wistream::_M_extract(long double&);
-  template wistream& wistream::_M_extract(void*&);
-#endif
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace
-
-// XXX GLIBCXX_ABI Deprecated
-#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
-
-#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
-  extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
-_GLIBCXX_LDBL_COMPAT (_ZNSirsERd, _ZNSirsERe);
-#ifdef _GLIBCXX_USE_WCHAR_T
-_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_istreamIwSt11char_traitsIwEErsERd,
-		      _ZNSt13basic_istreamIwSt11char_traitsIwEErsERe);
-#endif
-_GLIBCXX_LDBL_COMPAT (_ZNSi10_M_extractIdEERSiRT_,
-		      _ZNSi10_M_extractIeEERSiRT_);
-#ifdef _GLIBCXX_USE_WCHAR_T
-_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractIdEERS2_RT_,
-		      _ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractIeEERS2_RT_);
-#endif
-
-#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
diff --git a/libstdc++-v3/src/c++98/misc-inst.cc b/libstdc++-v3/src/c++98/misc-inst.cc
index 1c414fc..540e76d 100644
--- a/libstdc++-v3/src/c++98/misc-inst.cc
+++ b/libstdc++-v3/src/c++98/misc-inst.cc
@@ -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/src/c++98/ostream-inst.cc b/libstdc++-v3/src/c++98/ostream-inst.cc
deleted file mode 100644
index 5e8eab1..0000000
--- a/libstdc++-v3/src/c++98/ostream-inst.cc
+++ /dev/null
@@ -1,117 +0,0 @@ 
-// Explicit instantiation file.
-
-// Copyright (C) 1997-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/>.
-
-//
-// ISO C++ 14882:
-//
-
-#include <ostream>
-#include <iomanip>
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  // ostream
-  template class basic_ostream<char>;
-  template ostream& endl(ostream&);
-  template ostream& ends(ostream&);
-  template ostream& flush(ostream&);
-  template ostream& operator<<(ostream&, char);
-  template ostream& operator<<(ostream&, unsigned char);
-  template ostream& operator<<(ostream&, signed char);
-  template ostream& operator<<(ostream&, const char*);
-  template ostream& operator<<(ostream&, const unsigned char*);
-  template ostream& operator<<(ostream&, const signed char*);
-
-  template ostream& operator<<(ostream&, _Setfill<char>);
-  template ostream& operator<<(ostream&, _Setiosflags);
-  template ostream& operator<<(ostream&, _Resetiosflags);
-  template ostream& operator<<(ostream&, _Setbase);
-  template ostream& operator<<(ostream&, _Setprecision);
-  template ostream& operator<<(ostream&, _Setw);
-  template ostream& __ostream_insert(ostream&, const char*, streamsize);
-
-  template ostream& ostream::_M_insert(long);
-  template ostream& ostream::_M_insert(unsigned long);
-  template ostream& ostream::_M_insert(bool);
-#ifdef _GLIBCXX_USE_LONG_LONG
-  template ostream& ostream::_M_insert(long long);
-  template ostream& ostream::_M_insert(unsigned long long);
-#endif
-  template ostream& ostream::_M_insert(double);
-  template ostream& ostream::_M_insert(long double);
-  template ostream& ostream::_M_insert(const void*);
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  template class basic_ostream<wchar_t>;
-  template wostream& endl(wostream&);
-  template wostream& ends(wostream&);
-  template wostream& flush(wostream&);
-  template wostream& operator<<(wostream&, wchar_t);
-  template wostream& operator<<(wostream&, char);
-  template wostream& operator<<(wostream&, const wchar_t*);
-  template wostream& operator<<(wostream&, const char*);
-
-  template wostream& operator<<(wostream&, _Setfill<wchar_t>);
-  template wostream& operator<<(wostream&, _Setiosflags);
-  template wostream& operator<<(wostream&, _Resetiosflags);
-  template wostream& operator<<(wostream&, _Setbase);
-  template wostream& operator<<(wostream&, _Setprecision);
-  template wostream& operator<<(wostream&, _Setw);
-  template wostream& __ostream_insert(wostream&, const wchar_t*, streamsize);
-
-  template wostream& wostream::_M_insert(long);
-  template wostream& wostream::_M_insert(unsigned long);
-  template wostream& wostream::_M_insert(bool);
-#ifdef _GLIBCXX_USE_LONG_LONG
-  template wostream& wostream::_M_insert(long long);
-  template wostream& wostream::_M_insert(unsigned long long);
-#endif
-  template wostream& wostream::_M_insert(double);
-  template wostream& wostream::_M_insert(long double);
-  template wostream& wostream::_M_insert(const void*);
-#endif
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace
-
-// XXX GLIBCXX_ABI Deprecated
-#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
-
-#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
-  extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
-_GLIBCXX_LDBL_COMPAT (_ZNSolsEd, _ZNSolsEe);
-#ifdef _GLIBCXX_USE_WCHAR_T
-_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEd,
-		      _ZNSt13basic_ostreamIwSt11char_traitsIwEElsEe);
-#endif
-_GLIBCXX_LDBL_COMPAT (_ZNSo9_M_insertIdEERSoT_,
-		      _ZNSo9_M_insertIeEERSoT_);
-#ifdef _GLIBCXX_USE_WCHAR_T
-_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_,
-		      _ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIeEERS2_T_);
-#endif
-
-#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
diff --git a/libstdc++-v3/src/c++98/sstream-inst.cc b/libstdc++-v3/src/c++98/sstream-inst.cc
deleted file mode 100644
index 728946e..0000000
--- a/libstdc++-v3/src/c++98/sstream-inst.cc
+++ /dev/null
@@ -1,48 +0,0 @@ 
-// Explicit instantiation file.
-
-// Copyright (C) 1997-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/>.
-
-//
-// ISO C++ 14882:
-//
-
-#include <sstream>
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  template class basic_stringbuf<char>;
-  template class basic_istringstream<char>;
-  template class basic_ostringstream<char>;
-  template class basic_stringstream<char>;
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  template class basic_stringbuf<wchar_t>;
-  template class basic_istringstream<wchar_t>; 
-  template class basic_ostringstream<wchar_t>; 
-  template class basic_stringstream<wchar_t>; 
-#endif
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace
diff --git a/libstdc++-v3/src/c++98/streambuf-inst.cc b/libstdc++-v3/src/c++98/streambuf-inst.cc
deleted file mode 100644
index e79d627..0000000
--- a/libstdc++-v3/src/c++98/streambuf-inst.cc
+++ /dev/null
@@ -1,63 +0,0 @@ 
-// Explicit instantiation file.
-
-// Copyright (C) 1997-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/>.
-
-//
-// ISO C++ 14882:
-//
-
-#include <ios>
-#include <streambuf>
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
-  // streambuf
-  template class basic_streambuf<char>;
-
-  template
-    streamsize
-    __copy_streambufs(basic_streambuf<char>*, basic_streambuf<char>*);
-
-  template
-    streamsize
-    __copy_streambufs_eof(basic_streambuf<char>*,
-			  basic_streambuf<char>*, bool&);
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  // wstreambuf
-  template class basic_streambuf<wchar_t>;
-
-  template
-    streamsize
-    __copy_streambufs(basic_streambuf<wchar_t>*, basic_streambuf<wchar_t>*);
-
-  template
-    streamsize
-    __copy_streambufs_eof(basic_streambuf<wchar_t>*,
-			  basic_streambuf<wchar_t>*, bool&);
-#endif
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace