xref: /dflybsd-src/contrib/gcc-8.0/libstdc++-v3/include/std/streambuf (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj// Stream buffer classes -*- C++ -*-
2*38fd1498Szrj
3*38fd1498Szrj// Copyright (C) 1997-2018 Free Software Foundation, Inc.
4*38fd1498Szrj//
5*38fd1498Szrj// This file is part of the GNU ISO C++ Library.  This library is free
6*38fd1498Szrj// software; you can redistribute it and/or modify it under the
7*38fd1498Szrj// terms of the GNU General Public License as published by the
8*38fd1498Szrj// Free Software Foundation; either version 3, or (at your option)
9*38fd1498Szrj// any later version.
10*38fd1498Szrj
11*38fd1498Szrj// This library is distributed in the hope that it will be useful,
12*38fd1498Szrj// but WITHOUT ANY WARRANTY; without even the implied warranty of
13*38fd1498Szrj// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*38fd1498Szrj// GNU General Public License for more details.
15*38fd1498Szrj
16*38fd1498Szrj// Under Section 7 of GPL version 3, you are granted additional
17*38fd1498Szrj// permissions described in the GCC Runtime Library Exception, version
18*38fd1498Szrj// 3.1, as published by the Free Software Foundation.
19*38fd1498Szrj
20*38fd1498Szrj// You should have received a copy of the GNU General Public License and
21*38fd1498Szrj// a copy of the GCC Runtime Library Exception along with this program;
22*38fd1498Szrj// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23*38fd1498Szrj// <http://www.gnu.org/licenses/>.
24*38fd1498Szrj
25*38fd1498Szrj/** @file include/streambuf
26*38fd1498Szrj *  This is a Standard C++ Library header.
27*38fd1498Szrj */
28*38fd1498Szrj
29*38fd1498Szrj//
30*38fd1498Szrj// ISO C++ 14882: 27.5  Stream buffers
31*38fd1498Szrj//
32*38fd1498Szrj
33*38fd1498Szrj#ifndef _GLIBXX_STREAMBUF
34*38fd1498Szrj#define _GLIBXX_STREAMBUF 1
35*38fd1498Szrj
36*38fd1498Szrj#pragma GCC system_header
37*38fd1498Szrj
38*38fd1498Szrj#include <bits/c++config.h>
39*38fd1498Szrj#include <iosfwd>
40*38fd1498Szrj#include <bits/localefwd.h>
41*38fd1498Szrj#include <bits/ios_base.h>
42*38fd1498Szrj#include <bits/cpp_type_traits.h>
43*38fd1498Szrj#include <ext/type_traits.h>
44*38fd1498Szrj
45*38fd1498Szrjnamespace std _GLIBCXX_VISIBILITY(default)
46*38fd1498Szrj{
47*38fd1498Szrj_GLIBCXX_BEGIN_NAMESPACE_VERSION
48*38fd1498Szrj
49*38fd1498Szrj#define _IsUnused __attribute__ ((__unused__))
50*38fd1498Szrj
51*38fd1498Szrj  template<typename _CharT, typename _Traits>
52*38fd1498Szrj    streamsize
53*38fd1498Szrj    __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
54*38fd1498Szrj			  basic_streambuf<_CharT, _Traits>*, bool&);
55*38fd1498Szrj
56*38fd1498Szrj  /**
57*38fd1498Szrj   *  @brief  The actual work of input and output (interface).
58*38fd1498Szrj   *  @ingroup io
59*38fd1498Szrj   *
60*38fd1498Szrj   *  @tparam _CharT  Type of character stream.
61*38fd1498Szrj   *  @tparam _Traits  Traits for character type, defaults to
62*38fd1498Szrj   *                   char_traits<_CharT>.
63*38fd1498Szrj   *
64*38fd1498Szrj   *  This is a base class.  Derived stream buffers each control a
65*38fd1498Szrj   *  pair of character sequences:  one for input, and one for output.
66*38fd1498Szrj   *
67*38fd1498Szrj   *  Section [27.5.1] of the standard describes the requirements and
68*38fd1498Szrj   *  behavior of stream buffer classes.  That section (three paragraphs)
69*38fd1498Szrj   *  is reproduced here, for simplicity and accuracy.
70*38fd1498Szrj   *
71*38fd1498Szrj   *  -# Stream buffers can impose various constraints on the sequences
72*38fd1498Szrj   *     they control.  Some constraints are:
73*38fd1498Szrj   *     - The controlled input sequence can be not readable.
74*38fd1498Szrj   *     - The controlled output sequence can be not writable.
75*38fd1498Szrj   *     - The controlled sequences can be associated with the contents of
76*38fd1498Szrj   *       other representations for character sequences, such as external
77*38fd1498Szrj   *       files.
78*38fd1498Szrj   *     - The controlled sequences can support operations @e directly to or
79*38fd1498Szrj   *       from associated sequences.
80*38fd1498Szrj   *     - The controlled sequences can impose limitations on how the
81*38fd1498Szrj   *       program can read characters from a sequence, write characters to
82*38fd1498Szrj   *       a sequence, put characters back into an input sequence, or alter
83*38fd1498Szrj   *       the stream position.
84*38fd1498Szrj   *     .
85*38fd1498Szrj   *  -# Each sequence is characterized by three pointers which, if non-null,
86*38fd1498Szrj   *     all point into the same @c charT array object.  The array object
87*38fd1498Szrj   *     represents, at any moment, a (sub)sequence of characters from the
88*38fd1498Szrj   *     sequence.  Operations performed on a sequence alter the values
89*38fd1498Szrj   *     stored in these pointers, perform reads and writes directly to or
90*38fd1498Szrj   *     from associated sequences, and alter <em>the stream position</em> and
91*38fd1498Szrj   *     conversion state as needed to maintain this subsequence relationship.
92*38fd1498Szrj   *     The three pointers are:
93*38fd1498Szrj   *     - the <em>beginning pointer</em>, or lowest element address in the
94*38fd1498Szrj   *       array (called @e xbeg here);
95*38fd1498Szrj   *     - the <em>next pointer</em>, or next element address that is a
96*38fd1498Szrj   *       current candidate for reading or writing (called @e xnext here);
97*38fd1498Szrj   *     - the <em>end pointer</em>, or first element address beyond the
98*38fd1498Szrj   *       end of the array (called @e xend here).
99*38fd1498Szrj   *     .
100*38fd1498Szrj   *  -# The following semantic constraints shall always apply for any set
101*38fd1498Szrj   *     of three pointers for a sequence, using the pointer names given
102*38fd1498Szrj   *     immediately above:
103*38fd1498Szrj   *     - If @e xnext is not a null pointer, then @e xbeg and @e xend shall
104*38fd1498Szrj   *       also be non-null pointers into the same @c charT array, as
105*38fd1498Szrj   *       described above; otherwise, @e xbeg and @e xend shall also be null.
106*38fd1498Szrj   *     - If @e xnext is not a null pointer and @e xnext < @e xend for an
107*38fd1498Szrj   *       output sequence, then a <em>write position</em> is available.
108*38fd1498Szrj   *       In this case, @e *xnext shall be assignable as the next element
109*38fd1498Szrj   *       to write (to put, or to store a character value, into the sequence).
110*38fd1498Szrj   *     - If @e xnext is not a null pointer and @e xbeg < @e xnext for an
111*38fd1498Szrj   *       input sequence, then a <em>putback position</em> is available.
112*38fd1498Szrj   *       In this case, @e xnext[-1] shall have a defined value and is the
113*38fd1498Szrj   *       next (preceding) element to store a character that is put back
114*38fd1498Szrj   *       into the input sequence.
115*38fd1498Szrj   *     - If @e xnext is not a null pointer and @e xnext< @e xend for an
116*38fd1498Szrj   *       input sequence, then a <em>read position</em> is available.
117*38fd1498Szrj   *       In this case, @e *xnext shall have a defined value and is the
118*38fd1498Szrj   *       next element to read (to get, or to obtain a character value,
119*38fd1498Szrj   *       from the sequence).
120*38fd1498Szrj  */
121*38fd1498Szrj  template<typename _CharT, typename _Traits>
122*38fd1498Szrj    class basic_streambuf
123*38fd1498Szrj    {
124*38fd1498Szrj    public:
125*38fd1498Szrj      //@{
126*38fd1498Szrj      /**
127*38fd1498Szrj       *  These are standard types.  They permit a standardized way of
128*38fd1498Szrj       *  referring to names of (or names dependent on) the template
129*38fd1498Szrj       *  parameters, which are specific to the implementation.
130*38fd1498Szrj      */
131*38fd1498Szrj      typedef _CharT 					char_type;
132*38fd1498Szrj      typedef _Traits 					traits_type;
133*38fd1498Szrj      typedef typename traits_type::int_type 		int_type;
134*38fd1498Szrj      typedef typename traits_type::pos_type 		pos_type;
135*38fd1498Szrj      typedef typename traits_type::off_type 		off_type;
136*38fd1498Szrj      //@}
137*38fd1498Szrj
138*38fd1498Szrj      //@{
139*38fd1498Szrj      /// This is a non-standard type.
140*38fd1498Szrj      typedef basic_streambuf<char_type, traits_type>  	__streambuf_type;
141*38fd1498Szrj      //@}
142*38fd1498Szrj
143*38fd1498Szrj      friend class basic_ios<char_type, traits_type>;
144*38fd1498Szrj      friend class basic_istream<char_type, traits_type>;
145*38fd1498Szrj      friend class basic_ostream<char_type, traits_type>;
146*38fd1498Szrj      friend class istreambuf_iterator<char_type, traits_type>;
147*38fd1498Szrj      friend class ostreambuf_iterator<char_type, traits_type>;
148*38fd1498Szrj
149*38fd1498Szrj      friend streamsize
150*38fd1498Szrj      __copy_streambufs_eof<>(basic_streambuf*, basic_streambuf*, bool&);
151*38fd1498Szrj
152*38fd1498Szrj      template<bool _IsMove, typename _CharT2>
153*38fd1498Szrj        friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
154*38fd1498Szrj					       _CharT2*>::__type
155*38fd1498Szrj        __copy_move_a2(istreambuf_iterator<_CharT2>,
156*38fd1498Szrj		       istreambuf_iterator<_CharT2>, _CharT2*);
157*38fd1498Szrj
158*38fd1498Szrj      template<typename _CharT2>
159*38fd1498Szrj        friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
160*38fd1498Szrj				  istreambuf_iterator<_CharT2> >::__type
161*38fd1498Szrj        find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
162*38fd1498Szrj	     const _CharT2&);
163*38fd1498Szrj
164*38fd1498Szrj      template<typename _CharT2, typename _Distance>
165*38fd1498Szrj        friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
166*38fd1498Szrj					       void>::__type
167*38fd1498Szrj        advance(istreambuf_iterator<_CharT2>&, _Distance);
168*38fd1498Szrj
169*38fd1498Szrj      template<typename _CharT2, typename _Traits2>
170*38fd1498Szrj        friend basic_istream<_CharT2, _Traits2>&
171*38fd1498Szrj        operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
172*38fd1498Szrj
173*38fd1498Szrj      template<typename _CharT2, typename _Traits2, typename _Alloc>
174*38fd1498Szrj        friend basic_istream<_CharT2, _Traits2>&
175*38fd1498Szrj        operator>>(basic_istream<_CharT2, _Traits2>&,
176*38fd1498Szrj		   basic_string<_CharT2, _Traits2, _Alloc>&);
177*38fd1498Szrj
178*38fd1498Szrj      template<typename _CharT2, typename _Traits2, typename _Alloc>
179*38fd1498Szrj        friend basic_istream<_CharT2, _Traits2>&
180*38fd1498Szrj        getline(basic_istream<_CharT2, _Traits2>&,
181*38fd1498Szrj		basic_string<_CharT2, _Traits2, _Alloc>&, _CharT2);
182*38fd1498Szrj
183*38fd1498Szrj    protected:
184*38fd1498Szrj      /*
185*38fd1498Szrj       *  This is based on _IO_FILE, just reordered to be more consistent,
186*38fd1498Szrj       *  and is intended to be the most minimal abstraction for an
187*38fd1498Szrj       *  internal buffer.
188*38fd1498Szrj       *  -  get == input == read
189*38fd1498Szrj       *  -  put == output == write
190*38fd1498Szrj      */
191*38fd1498Szrj      char_type* 		_M_in_beg;     ///< Start of get area.
192*38fd1498Szrj      char_type* 		_M_in_cur;     ///< Current read area.
193*38fd1498Szrj      char_type* 		_M_in_end;     ///< End of get area.
194*38fd1498Szrj      char_type* 		_M_out_beg;    ///< Start of put area.
195*38fd1498Szrj      char_type* 		_M_out_cur;    ///< Current put area.
196*38fd1498Szrj      char_type* 		_M_out_end;    ///< End of put area.
197*38fd1498Szrj
198*38fd1498Szrj      /// Current locale setting.
199*38fd1498Szrj      locale 			_M_buf_locale;
200*38fd1498Szrj
201*38fd1498Szrj  public:
202*38fd1498Szrj      /// Destructor deallocates no buffer space.
203*38fd1498Szrj      virtual
204*38fd1498Szrj      ~basic_streambuf()
205*38fd1498Szrj      { }
206*38fd1498Szrj
207*38fd1498Szrj      // [27.5.2.2.1] locales
208*38fd1498Szrj      /**
209*38fd1498Szrj       *  @brief  Entry point for imbue().
210*38fd1498Szrj       *  @param  __loc  The new locale.
211*38fd1498Szrj       *  @return  The previous locale.
212*38fd1498Szrj       *
213*38fd1498Szrj       *  Calls the derived imbue(__loc).
214*38fd1498Szrj      */
215*38fd1498Szrj      locale
216*38fd1498Szrj      pubimbue(const locale& __loc)
217*38fd1498Szrj      {
218*38fd1498Szrj	locale __tmp(this->getloc());
219*38fd1498Szrj	this->imbue(__loc);
220*38fd1498Szrj	_M_buf_locale = __loc;
221*38fd1498Szrj	return __tmp;
222*38fd1498Szrj      }
223*38fd1498Szrj
224*38fd1498Szrj      /**
225*38fd1498Szrj       *  @brief  Locale access.
226*38fd1498Szrj       *  @return  The current locale in effect.
227*38fd1498Szrj       *
228*38fd1498Szrj       *  If pubimbue(loc) has been called, then the most recent @c loc
229*38fd1498Szrj       *  is returned.  Otherwise the global locale in effect at the time
230*38fd1498Szrj       *  of construction is returned.
231*38fd1498Szrj      */
232*38fd1498Szrj      locale
233*38fd1498Szrj      getloc() const
234*38fd1498Szrj      { return _M_buf_locale; }
235*38fd1498Szrj
236*38fd1498Szrj      // [27.5.2.2.2] buffer management and positioning
237*38fd1498Szrj      //@{
238*38fd1498Szrj      /**
239*38fd1498Szrj       *  @brief  Entry points for derived buffer functions.
240*38fd1498Szrj       *
241*38fd1498Szrj       *  The public versions of @c pubfoo dispatch to the protected
242*38fd1498Szrj       *  derived @c foo member functions, passing the arguments (if any)
243*38fd1498Szrj       *  and returning the result unchanged.
244*38fd1498Szrj      */
245*38fd1498Szrj      basic_streambuf*
246*38fd1498Szrj      pubsetbuf(char_type* __s, streamsize __n)
247*38fd1498Szrj      { return this->setbuf(__s, __n); }
248*38fd1498Szrj
249*38fd1498Szrj      /**
250*38fd1498Szrj       *  @brief  Alters the stream position.
251*38fd1498Szrj       *  @param  __off  Offset.
252*38fd1498Szrj       *  @param  __way  Value for ios_base::seekdir.
253*38fd1498Szrj       *  @param  __mode Value for ios_base::openmode.
254*38fd1498Szrj       *
255*38fd1498Szrj       *  Calls virtual seekoff function.
256*38fd1498Szrj      */
257*38fd1498Szrj      pos_type
258*38fd1498Szrj      pubseekoff(off_type __off, ios_base::seekdir __way,
259*38fd1498Szrj		 ios_base::openmode __mode = ios_base::in | ios_base::out)
260*38fd1498Szrj      { return this->seekoff(__off, __way, __mode); }
261*38fd1498Szrj
262*38fd1498Szrj      /**
263*38fd1498Szrj       *  @brief  Alters the stream position.
264*38fd1498Szrj       *  @param  __sp  Position
265*38fd1498Szrj       *  @param  __mode Value for ios_base::openmode.
266*38fd1498Szrj       *
267*38fd1498Szrj       *  Calls virtual seekpos function.
268*38fd1498Szrj      */
269*38fd1498Szrj      pos_type
270*38fd1498Szrj      pubseekpos(pos_type __sp,
271*38fd1498Szrj		 ios_base::openmode __mode = ios_base::in | ios_base::out)
272*38fd1498Szrj      { return this->seekpos(__sp, __mode); }
273*38fd1498Szrj
274*38fd1498Szrj      /**
275*38fd1498Szrj       *  @brief  Calls virtual sync function.
276*38fd1498Szrj      */
277*38fd1498Szrj      int
278*38fd1498Szrj      pubsync() { return this->sync(); }
279*38fd1498Szrj      //@}
280*38fd1498Szrj
281*38fd1498Szrj      // [27.5.2.2.3] get area
282*38fd1498Szrj      /**
283*38fd1498Szrj       *  @brief  Looking ahead into the stream.
284*38fd1498Szrj       *  @return  The number of characters available.
285*38fd1498Szrj       *
286*38fd1498Szrj       *  If a read position is available, returns the number of characters
287*38fd1498Szrj       *  available for reading before the buffer must be refilled.
288*38fd1498Szrj       *  Otherwise returns the derived @c showmanyc().
289*38fd1498Szrj      */
290*38fd1498Szrj      streamsize
291*38fd1498Szrj      in_avail()
292*38fd1498Szrj      {
293*38fd1498Szrj	const streamsize __ret = this->egptr() - this->gptr();
294*38fd1498Szrj	return __ret ? __ret : this->showmanyc();
295*38fd1498Szrj      }
296*38fd1498Szrj
297*38fd1498Szrj      /**
298*38fd1498Szrj       *  @brief  Getting the next character.
299*38fd1498Szrj       *  @return  The next character, or eof.
300*38fd1498Szrj       *
301*38fd1498Szrj       *  Calls @c sbumpc(), and if that function returns
302*38fd1498Szrj       *  @c traits::eof(), so does this function.  Otherwise, @c sgetc().
303*38fd1498Szrj      */
304*38fd1498Szrj      int_type
305*38fd1498Szrj      snextc()
306*38fd1498Szrj      {
307*38fd1498Szrj	int_type __ret = traits_type::eof();
308*38fd1498Szrj	if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(),
309*38fd1498Szrj						       __ret), true))
310*38fd1498Szrj	  __ret = this->sgetc();
311*38fd1498Szrj	return __ret;
312*38fd1498Szrj      }
313*38fd1498Szrj
314*38fd1498Szrj      /**
315*38fd1498Szrj       *  @brief  Getting the next character.
316*38fd1498Szrj       *  @return  The next character, or eof.
317*38fd1498Szrj       *
318*38fd1498Szrj       *  If the input read position is available, returns that character
319*38fd1498Szrj       *  and increments the read pointer, otherwise calls and returns
320*38fd1498Szrj       *  @c uflow().
321*38fd1498Szrj      */
322*38fd1498Szrj      int_type
323*38fd1498Szrj      sbumpc()
324*38fd1498Szrj      {
325*38fd1498Szrj	int_type __ret;
326*38fd1498Szrj	if (__builtin_expect(this->gptr() < this->egptr(), true))
327*38fd1498Szrj	  {
328*38fd1498Szrj	    __ret = traits_type::to_int_type(*this->gptr());
329*38fd1498Szrj	    this->gbump(1);
330*38fd1498Szrj	  }
331*38fd1498Szrj	else
332*38fd1498Szrj	  __ret = this->uflow();
333*38fd1498Szrj	return __ret;
334*38fd1498Szrj      }
335*38fd1498Szrj
336*38fd1498Szrj      /**
337*38fd1498Szrj       *  @brief  Getting the next character.
338*38fd1498Szrj       *  @return  The next character, or eof.
339*38fd1498Szrj       *
340*38fd1498Szrj       *  If the input read position is available, returns that character,
341*38fd1498Szrj       *  otherwise calls and returns @c underflow().  Does not move the
342*38fd1498Szrj       *  read position after fetching the character.
343*38fd1498Szrj      */
344*38fd1498Szrj      int_type
345*38fd1498Szrj      sgetc()
346*38fd1498Szrj      {
347*38fd1498Szrj	int_type __ret;
348*38fd1498Szrj	if (__builtin_expect(this->gptr() < this->egptr(), true))
349*38fd1498Szrj	  __ret = traits_type::to_int_type(*this->gptr());
350*38fd1498Szrj	else
351*38fd1498Szrj	  __ret = this->underflow();
352*38fd1498Szrj	return __ret;
353*38fd1498Szrj      }
354*38fd1498Szrj
355*38fd1498Szrj      /**
356*38fd1498Szrj       *  @brief  Entry point for xsgetn.
357*38fd1498Szrj       *  @param  __s  A buffer area.
358*38fd1498Szrj       *  @param  __n  A count.
359*38fd1498Szrj       *
360*38fd1498Szrj       *  Returns xsgetn(__s,__n).  The effect is to fill @a __s[0] through
361*38fd1498Szrj       *  @a __s[__n-1] with characters from the input sequence, if possible.
362*38fd1498Szrj      */
363*38fd1498Szrj      streamsize
364*38fd1498Szrj      sgetn(char_type* __s, streamsize __n)
365*38fd1498Szrj      { return this->xsgetn(__s, __n); }
366*38fd1498Szrj
367*38fd1498Szrj      // [27.5.2.2.4] putback
368*38fd1498Szrj      /**
369*38fd1498Szrj       *  @brief  Pushing characters back into the input stream.
370*38fd1498Szrj       *  @param  __c  The character to push back.
371*38fd1498Szrj       *  @return  The previous character, if possible.
372*38fd1498Szrj       *
373*38fd1498Szrj       *  Similar to sungetc(), but @a __c is pushed onto the stream
374*38fd1498Szrj       *  instead of <em>the previous character.</em> If successful,
375*38fd1498Szrj       *  the next character fetched from the input stream will be @a
376*38fd1498Szrj       *  __c.
377*38fd1498Szrj      */
378*38fd1498Szrj      int_type
379*38fd1498Szrj      sputbackc(char_type __c)
380*38fd1498Szrj      {
381*38fd1498Szrj	int_type __ret;
382*38fd1498Szrj	const bool __testpos = this->eback() < this->gptr();
383*38fd1498Szrj	if (__builtin_expect(!__testpos ||
384*38fd1498Szrj			     !traits_type::eq(__c, this->gptr()[-1]), false))
385*38fd1498Szrj	  __ret = this->pbackfail(traits_type::to_int_type(__c));
386*38fd1498Szrj	else
387*38fd1498Szrj	  {
388*38fd1498Szrj	    this->gbump(-1);
389*38fd1498Szrj	    __ret = traits_type::to_int_type(*this->gptr());
390*38fd1498Szrj	  }
391*38fd1498Szrj	return __ret;
392*38fd1498Szrj      }
393*38fd1498Szrj
394*38fd1498Szrj      /**
395*38fd1498Szrj       *  @brief  Moving backwards in the input stream.
396*38fd1498Szrj       *  @return  The previous character, if possible.
397*38fd1498Szrj       *
398*38fd1498Szrj       *  If a putback position is available, this function decrements
399*38fd1498Szrj       *  the input pointer and returns that character.  Otherwise,
400*38fd1498Szrj       *  calls and returns pbackfail().  The effect is to @a unget
401*38fd1498Szrj       *  the last character @a gotten.
402*38fd1498Szrj      */
403*38fd1498Szrj      int_type
404*38fd1498Szrj      sungetc()
405*38fd1498Szrj      {
406*38fd1498Szrj	int_type __ret;
407*38fd1498Szrj	if (__builtin_expect(this->eback() < this->gptr(), true))
408*38fd1498Szrj	  {
409*38fd1498Szrj	    this->gbump(-1);
410*38fd1498Szrj	    __ret = traits_type::to_int_type(*this->gptr());
411*38fd1498Szrj	  }
412*38fd1498Szrj	else
413*38fd1498Szrj	  __ret = this->pbackfail();
414*38fd1498Szrj	return __ret;
415*38fd1498Szrj      }
416*38fd1498Szrj
417*38fd1498Szrj      // [27.5.2.2.5] put area
418*38fd1498Szrj      /**
419*38fd1498Szrj       *  @brief  Entry point for all single-character output functions.
420*38fd1498Szrj       *  @param  __c  A character to output.
421*38fd1498Szrj       *  @return  @a __c, if possible.
422*38fd1498Szrj       *
423*38fd1498Szrj       *  One of two public output functions.
424*38fd1498Szrj       *
425*38fd1498Szrj       *  If a write position is available for the output sequence (i.e.,
426*38fd1498Szrj       *  the buffer is not full), stores @a __c in that position, increments
427*38fd1498Szrj       *  the position, and returns @c traits::to_int_type(__c).  If a write
428*38fd1498Szrj       *  position is not available, returns @c overflow(__c).
429*38fd1498Szrj      */
430*38fd1498Szrj      int_type
431*38fd1498Szrj      sputc(char_type __c)
432*38fd1498Szrj      {
433*38fd1498Szrj	int_type __ret;
434*38fd1498Szrj	if (__builtin_expect(this->pptr() < this->epptr(), true))
435*38fd1498Szrj	  {
436*38fd1498Szrj	    *this->pptr() = __c;
437*38fd1498Szrj	    this->pbump(1);
438*38fd1498Szrj	    __ret = traits_type::to_int_type(__c);
439*38fd1498Szrj	  }
440*38fd1498Szrj	else
441*38fd1498Szrj	  __ret = this->overflow(traits_type::to_int_type(__c));
442*38fd1498Szrj	return __ret;
443*38fd1498Szrj      }
444*38fd1498Szrj
445*38fd1498Szrj      /**
446*38fd1498Szrj       *  @brief  Entry point for all single-character output functions.
447*38fd1498Szrj       *  @param  __s  A buffer read area.
448*38fd1498Szrj       *  @param  __n  A count.
449*38fd1498Szrj       *
450*38fd1498Szrj       *  One of two public output functions.
451*38fd1498Szrj       *
452*38fd1498Szrj       *
453*38fd1498Szrj       *  Returns xsputn(__s,__n).  The effect is to write @a __s[0] through
454*38fd1498Szrj       *  @a __s[__n-1] to the output sequence, if possible.
455*38fd1498Szrj      */
456*38fd1498Szrj      streamsize
457*38fd1498Szrj      sputn(const char_type* __s, streamsize __n)
458*38fd1498Szrj      { return this->xsputn(__s, __n); }
459*38fd1498Szrj
460*38fd1498Szrj    protected:
461*38fd1498Szrj      /**
462*38fd1498Szrj       *  @brief  Base constructor.
463*38fd1498Szrj       *
464*38fd1498Szrj       *  Only called from derived constructors, and sets up all the
465*38fd1498Szrj       *  buffer data to zero, including the pointers described in the
466*38fd1498Szrj       *  basic_streambuf class description.  Note that, as a result,
467*38fd1498Szrj       *  - the class starts with no read nor write positions available,
468*38fd1498Szrj       *  - this is not an error
469*38fd1498Szrj      */
470*38fd1498Szrj      basic_streambuf()
471*38fd1498Szrj      : _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
472*38fd1498Szrj      _M_out_beg(0), _M_out_cur(0), _M_out_end(0),
473*38fd1498Szrj      _M_buf_locale(locale())
474*38fd1498Szrj      { }
475*38fd1498Szrj
476*38fd1498Szrj      // [27.5.2.3.1] get area access
477*38fd1498Szrj      //@{
478*38fd1498Szrj      /**
479*38fd1498Szrj       *  @brief  Access to the get area.
480*38fd1498Szrj       *
481*38fd1498Szrj       *  These functions are only available to other protected functions,
482*38fd1498Szrj       *  including derived classes.
483*38fd1498Szrj       *
484*38fd1498Szrj       *  - eback() returns the beginning pointer for the input sequence
485*38fd1498Szrj       *  - gptr() returns the next pointer for the input sequence
486*38fd1498Szrj       *  - egptr() returns the end pointer for the input sequence
487*38fd1498Szrj      */
488*38fd1498Szrj      char_type*
489*38fd1498Szrj      eback() const { return _M_in_beg; }
490*38fd1498Szrj
491*38fd1498Szrj      char_type*
492*38fd1498Szrj      gptr()  const { return _M_in_cur;  }
493*38fd1498Szrj
494*38fd1498Szrj      char_type*
495*38fd1498Szrj      egptr() const { return _M_in_end; }
496*38fd1498Szrj      //@}
497*38fd1498Szrj
498*38fd1498Szrj      /**
499*38fd1498Szrj       *  @brief  Moving the read position.
500*38fd1498Szrj       *  @param  __n  The delta by which to move.
501*38fd1498Szrj       *
502*38fd1498Szrj       *  This just advances the read position without returning any data.
503*38fd1498Szrj      */
504*38fd1498Szrj      void
505*38fd1498Szrj      gbump(int __n) { _M_in_cur += __n; }
506*38fd1498Szrj
507*38fd1498Szrj      /**
508*38fd1498Szrj       *  @brief  Setting the three read area pointers.
509*38fd1498Szrj       *  @param  __gbeg  A pointer.
510*38fd1498Szrj       *  @param  __gnext  A pointer.
511*38fd1498Szrj       *  @param  __gend  A pointer.
512*38fd1498Szrj       *  @post  @a __gbeg == @c eback(), @a __gnext == @c gptr(), and
513*38fd1498Szrj       *         @a __gend == @c egptr()
514*38fd1498Szrj      */
515*38fd1498Szrj      void
516*38fd1498Szrj      setg(char_type* __gbeg, char_type* __gnext, char_type* __gend)
517*38fd1498Szrj      {
518*38fd1498Szrj	_M_in_beg = __gbeg;
519*38fd1498Szrj	_M_in_cur = __gnext;
520*38fd1498Szrj	_M_in_end = __gend;
521*38fd1498Szrj      }
522*38fd1498Szrj
523*38fd1498Szrj      // [27.5.2.3.2] put area access
524*38fd1498Szrj      //@{
525*38fd1498Szrj      /**
526*38fd1498Szrj       *  @brief  Access to the put area.
527*38fd1498Szrj       *
528*38fd1498Szrj       *  These functions are only available to other protected functions,
529*38fd1498Szrj       *  including derived classes.
530*38fd1498Szrj       *
531*38fd1498Szrj       *  - pbase() returns the beginning pointer for the output sequence
532*38fd1498Szrj       *  - pptr() returns the next pointer for the output sequence
533*38fd1498Szrj       *  - epptr() returns the end pointer for the output sequence
534*38fd1498Szrj      */
535*38fd1498Szrj      char_type*
536*38fd1498Szrj      pbase() const { return _M_out_beg; }
537*38fd1498Szrj
538*38fd1498Szrj      char_type*
539*38fd1498Szrj      pptr() const { return _M_out_cur; }
540*38fd1498Szrj
541*38fd1498Szrj      char_type*
542*38fd1498Szrj      epptr() const { return _M_out_end; }
543*38fd1498Szrj      //@}
544*38fd1498Szrj
545*38fd1498Szrj      /**
546*38fd1498Szrj       *  @brief  Moving the write position.
547*38fd1498Szrj       *  @param  __n  The delta by which to move.
548*38fd1498Szrj       *
549*38fd1498Szrj       *  This just advances the write position without returning any data.
550*38fd1498Szrj      */
551*38fd1498Szrj      void
552*38fd1498Szrj      pbump(int __n) { _M_out_cur += __n; }
553*38fd1498Szrj
554*38fd1498Szrj      /**
555*38fd1498Szrj       *  @brief  Setting the three write area pointers.
556*38fd1498Szrj       *  @param  __pbeg  A pointer.
557*38fd1498Szrj       *  @param  __pend  A pointer.
558*38fd1498Szrj       *  @post  @a __pbeg == @c pbase(), @a __pbeg == @c pptr(), and
559*38fd1498Szrj       *         @a __pend == @c epptr()
560*38fd1498Szrj      */
561*38fd1498Szrj      void
562*38fd1498Szrj      setp(char_type* __pbeg, char_type* __pend)
563*38fd1498Szrj      {
564*38fd1498Szrj	_M_out_beg = _M_out_cur = __pbeg;
565*38fd1498Szrj	_M_out_end = __pend;
566*38fd1498Szrj      }
567*38fd1498Szrj
568*38fd1498Szrj      // [27.5.2.4] virtual functions
569*38fd1498Szrj      // [27.5.2.4.1] locales
570*38fd1498Szrj      /**
571*38fd1498Szrj       *  @brief  Changes translations.
572*38fd1498Szrj       *  @param  __loc  A new locale.
573*38fd1498Szrj       *
574*38fd1498Szrj       *  Translations done during I/O which depend on the current
575*38fd1498Szrj       *  locale are changed by this call.  The standard adds,
576*38fd1498Szrj       *  <em>Between invocations of this function a class derived
577*38fd1498Szrj       *  from streambuf can safely cache results of calls to locale
578*38fd1498Szrj       *  functions and to members of facets so obtained.</em>
579*38fd1498Szrj       *
580*38fd1498Szrj       *  @note  Base class version does nothing.
581*38fd1498Szrj      */
582*38fd1498Szrj      virtual void
583*38fd1498Szrj      imbue(const locale& __loc _IsUnused)
584*38fd1498Szrj      { }
585*38fd1498Szrj
586*38fd1498Szrj      // [27.5.2.4.2] buffer management and positioning
587*38fd1498Szrj      /**
588*38fd1498Szrj       *  @brief  Manipulates the buffer.
589*38fd1498Szrj       *
590*38fd1498Szrj       *  Each derived class provides its own appropriate behavior.  See
591*38fd1498Szrj       *  the next-to-last paragraph of
592*38fd1498Szrj       *  https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering
593*38fd1498Szrj       *  for more on this function.
594*38fd1498Szrj       *
595*38fd1498Szrj       *  @note  Base class version does nothing, returns @c this.
596*38fd1498Szrj      */
597*38fd1498Szrj      virtual basic_streambuf<char_type,_Traits>*
598*38fd1498Szrj      setbuf(char_type*, streamsize)
599*38fd1498Szrj      {	return this; }
600*38fd1498Szrj
601*38fd1498Szrj      /**
602*38fd1498Szrj       *  @brief  Alters the stream positions.
603*38fd1498Szrj       *
604*38fd1498Szrj       *  Each derived class provides its own appropriate behavior.
605*38fd1498Szrj       *  @note  Base class version does nothing, returns a @c pos_type
606*38fd1498Szrj       *         that represents an invalid stream position.
607*38fd1498Szrj      */
608*38fd1498Szrj      virtual pos_type
609*38fd1498Szrj      seekoff(off_type, ios_base::seekdir,
610*38fd1498Szrj	      ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
611*38fd1498Szrj      { return pos_type(off_type(-1)); }
612*38fd1498Szrj
613*38fd1498Szrj      /**
614*38fd1498Szrj       *  @brief  Alters the stream positions.
615*38fd1498Szrj       *
616*38fd1498Szrj       *  Each derived class provides its own appropriate behavior.
617*38fd1498Szrj       *  @note  Base class version does nothing, returns a @c pos_type
618*38fd1498Szrj       *         that represents an invalid stream position.
619*38fd1498Szrj      */
620*38fd1498Szrj      virtual pos_type
621*38fd1498Szrj      seekpos(pos_type,
622*38fd1498Szrj	      ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
623*38fd1498Szrj      { return pos_type(off_type(-1)); }
624*38fd1498Szrj
625*38fd1498Szrj      /**
626*38fd1498Szrj       *  @brief  Synchronizes the buffer arrays with the controlled sequences.
627*38fd1498Szrj       *  @return  -1 on failure.
628*38fd1498Szrj       *
629*38fd1498Szrj       *  Each derived class provides its own appropriate behavior,
630*38fd1498Szrj       *  including the definition of @a failure.
631*38fd1498Szrj       *  @note  Base class version does nothing, returns zero.
632*38fd1498Szrj      */
633*38fd1498Szrj      virtual int
634*38fd1498Szrj      sync() { return 0; }
635*38fd1498Szrj
636*38fd1498Szrj      // [27.5.2.4.3] get area
637*38fd1498Szrj      /**
638*38fd1498Szrj       *  @brief  Investigating the data available.
639*38fd1498Szrj       *  @return  An estimate of the number of characters available in the
640*38fd1498Szrj       *           input sequence, or -1.
641*38fd1498Szrj       *
642*38fd1498Szrj       *  <em>If it returns a positive value, then successive calls to
643*38fd1498Szrj       *  @c underflow() will not return @c traits::eof() until at
644*38fd1498Szrj       *  least that number of characters have been supplied.  If @c
645*38fd1498Szrj       *  showmanyc() returns -1, then calls to @c underflow() or @c
646*38fd1498Szrj       *  uflow() will fail.</em> [27.5.2.4.3]/1
647*38fd1498Szrj       *
648*38fd1498Szrj       *  @note  Base class version does nothing, returns zero.
649*38fd1498Szrj       *  @note  The standard adds that <em>the intention is not only that the
650*38fd1498Szrj       *         calls [to underflow or uflow] will not return @c eof() but
651*38fd1498Szrj       *         that they will return immediately.</em>
652*38fd1498Szrj       *  @note  The standard adds that <em>the morphemes of @c showmanyc are
653*38fd1498Szrj       *         @b es-how-many-see, not @b show-manic.</em>
654*38fd1498Szrj      */
655*38fd1498Szrj      virtual streamsize
656*38fd1498Szrj      showmanyc() { return 0; }
657*38fd1498Szrj
658*38fd1498Szrj      /**
659*38fd1498Szrj       *  @brief  Multiple character extraction.
660*38fd1498Szrj       *  @param  __s  A buffer area.
661*38fd1498Szrj       *  @param  __n  Maximum number of characters to assign.
662*38fd1498Szrj       *  @return  The number of characters assigned.
663*38fd1498Szrj       *
664*38fd1498Szrj       *  Fills @a __s[0] through @a __s[__n-1] with characters from the input
665*38fd1498Szrj       *  sequence, as if by @c sbumpc().  Stops when either @a __n characters
666*38fd1498Szrj       *  have been copied, or when @c traits::eof() would be copied.
667*38fd1498Szrj       *
668*38fd1498Szrj       *  It is expected that derived classes provide a more efficient
669*38fd1498Szrj       *  implementation by overriding this definition.
670*38fd1498Szrj      */
671*38fd1498Szrj      virtual streamsize
672*38fd1498Szrj      xsgetn(char_type* __s, streamsize __n);
673*38fd1498Szrj
674*38fd1498Szrj      /**
675*38fd1498Szrj       *  @brief  Fetches more data from the controlled sequence.
676*38fd1498Szrj       *  @return  The first character from the <em>pending sequence</em>.
677*38fd1498Szrj       *
678*38fd1498Szrj       *  Informally, this function is called when the input buffer is
679*38fd1498Szrj       *  exhausted (or does not exist, as buffering need not actually be
680*38fd1498Szrj       *  done).  If a buffer exists, it is @a refilled.  In either case, the
681*38fd1498Szrj       *  next available character is returned, or @c traits::eof() to
682*38fd1498Szrj       *  indicate a null pending sequence.
683*38fd1498Szrj       *
684*38fd1498Szrj       *  For a formal definition of the pending sequence, see a good text
685*38fd1498Szrj       *  such as Langer & Kreft, or [27.5.2.4.3]/7-14.
686*38fd1498Szrj       *
687*38fd1498Szrj       *  A functioning input streambuf can be created by overriding only
688*38fd1498Szrj       *  this function (no buffer area will be used).  For an example, see
689*38fd1498Szrj       *  https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html
690*38fd1498Szrj       *
691*38fd1498Szrj       *  @note  Base class version does nothing, returns eof().
692*38fd1498Szrj      */
693*38fd1498Szrj      virtual int_type
694*38fd1498Szrj      underflow()
695*38fd1498Szrj      { return traits_type::eof(); }
696*38fd1498Szrj
697*38fd1498Szrj      /**
698*38fd1498Szrj       *  @brief  Fetches more data from the controlled sequence.
699*38fd1498Szrj       *  @return  The first character from the <em>pending sequence</em>.
700*38fd1498Szrj       *
701*38fd1498Szrj       *  Informally, this function does the same thing as @c underflow(),
702*38fd1498Szrj       *  and in fact is required to call that function.  It also returns
703*38fd1498Szrj       *  the new character, like @c underflow() does.  However, this
704*38fd1498Szrj       *  function also moves the read position forward by one.
705*38fd1498Szrj      */
706*38fd1498Szrj      virtual int_type
707*38fd1498Szrj      uflow()
708*38fd1498Szrj      {
709*38fd1498Szrj	int_type __ret = traits_type::eof();
710*38fd1498Szrj	const bool __testeof = traits_type::eq_int_type(this->underflow(),
711*38fd1498Szrj							__ret);
712*38fd1498Szrj	if (!__testeof)
713*38fd1498Szrj	  {
714*38fd1498Szrj	    __ret = traits_type::to_int_type(*this->gptr());
715*38fd1498Szrj	    this->gbump(1);
716*38fd1498Szrj	  }
717*38fd1498Szrj	return __ret;
718*38fd1498Szrj      }
719*38fd1498Szrj
720*38fd1498Szrj      // [27.5.2.4.4] putback
721*38fd1498Szrj      /**
722*38fd1498Szrj       *  @brief  Tries to back up the input sequence.
723*38fd1498Szrj       *  @param  __c  The character to be inserted back into the sequence.
724*38fd1498Szrj       *  @return  eof() on failure, <em>some other value</em> on success
725*38fd1498Szrj       *  @post  The constraints of @c gptr(), @c eback(), and @c pptr()
726*38fd1498Szrj       *         are the same as for @c underflow().
727*38fd1498Szrj       *
728*38fd1498Szrj       *  @note  Base class version does nothing, returns eof().
729*38fd1498Szrj      */
730*38fd1498Szrj      virtual int_type
731*38fd1498Szrj      pbackfail(int_type __c _IsUnused  = traits_type::eof())
732*38fd1498Szrj      { return traits_type::eof(); }
733*38fd1498Szrj
734*38fd1498Szrj      // Put area:
735*38fd1498Szrj      /**
736*38fd1498Szrj       *  @brief  Multiple character insertion.
737*38fd1498Szrj       *  @param  __s  A buffer area.
738*38fd1498Szrj       *  @param  __n  Maximum number of characters to write.
739*38fd1498Szrj       *  @return  The number of characters written.
740*38fd1498Szrj       *
741*38fd1498Szrj       *  Writes @a __s[0] through @a __s[__n-1] to the output sequence, as if
742*38fd1498Szrj       *  by @c sputc().  Stops when either @a n characters have been
743*38fd1498Szrj       *  copied, or when @c sputc() would return @c traits::eof().
744*38fd1498Szrj       *
745*38fd1498Szrj       *  It is expected that derived classes provide a more efficient
746*38fd1498Szrj       *  implementation by overriding this definition.
747*38fd1498Szrj      */
748*38fd1498Szrj      virtual streamsize
749*38fd1498Szrj      xsputn(const char_type* __s, streamsize __n);
750*38fd1498Szrj
751*38fd1498Szrj      /**
752*38fd1498Szrj       *  @brief  Consumes data from the buffer; writes to the
753*38fd1498Szrj       *          controlled sequence.
754*38fd1498Szrj       *  @param  __c  An additional character to consume.
755*38fd1498Szrj       *  @return  eof() to indicate failure, something else (usually
756*38fd1498Szrj       *           @a __c, or not_eof())
757*38fd1498Szrj       *
758*38fd1498Szrj       *  Informally, this function is called when the output buffer
759*38fd1498Szrj       *  is full (or does not exist, as buffering need not actually
760*38fd1498Szrj       *  be done).  If a buffer exists, it is @a consumed, with
761*38fd1498Szrj       *  <em>some effect</em> on the controlled sequence.
762*38fd1498Szrj       *  (Typically, the buffer is written out to the sequence
763*38fd1498Szrj       *  verbatim.)  In either case, the character @a c is also
764*38fd1498Szrj       *  written out, if @a __c is not @c eof().
765*38fd1498Szrj       *
766*38fd1498Szrj       *  For a formal definition of this function, see a good text
767*38fd1498Szrj       *  such as Langer & Kreft, or [27.5.2.4.5]/3-7.
768*38fd1498Szrj       *
769*38fd1498Szrj       *  A functioning output streambuf can be created by overriding only
770*38fd1498Szrj       *  this function (no buffer area will be used).
771*38fd1498Szrj       *
772*38fd1498Szrj       *  @note  Base class version does nothing, returns eof().
773*38fd1498Szrj      */
774*38fd1498Szrj      virtual int_type
775*38fd1498Szrj      overflow(int_type __c _IsUnused  = traits_type::eof())
776*38fd1498Szrj      { return traits_type::eof(); }
777*38fd1498Szrj
778*38fd1498Szrj#if _GLIBCXX_USE_DEPRECATED && __cplusplus <= 201402L
779*38fd1498Szrj    // Annex D.6 (removed in C++17)
780*38fd1498Szrj    public:
781*38fd1498Szrj      /**
782*38fd1498Szrj       *  @brief  Tosses a character.
783*38fd1498Szrj       *
784*38fd1498Szrj       *  Advances the read pointer, ignoring the character that would have
785*38fd1498Szrj       *  been read.
786*38fd1498Szrj       *
787*38fd1498Szrj       *  See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html
788*38fd1498Szrj       */
789*38fd1498Szrj#if __cplusplus >= 201103L
790*38fd1498Szrj      [[__deprecated__("stossc is deprecated, use sbumpc instead")]]
791*38fd1498Szrj#endif
792*38fd1498Szrj      void
793*38fd1498Szrj      stossc()
794*38fd1498Szrj      {
795*38fd1498Szrj	if (this->gptr() < this->egptr())
796*38fd1498Szrj	  this->gbump(1);
797*38fd1498Szrj	else
798*38fd1498Szrj	  this->uflow();
799*38fd1498Szrj      }
800*38fd1498Szrj#endif
801*38fd1498Szrj
802*38fd1498Szrj      // Also used by specializations for char and wchar_t in src.
803*38fd1498Szrj      void
804*38fd1498Szrj      __safe_gbump(streamsize __n) { _M_in_cur += __n; }
805*38fd1498Szrj
806*38fd1498Szrj      void
807*38fd1498Szrj      __safe_pbump(streamsize __n) { _M_out_cur += __n; }
808*38fd1498Szrj
809*38fd1498Szrj#if __cplusplus < 201103L
810*38fd1498Szrj    private:
811*38fd1498Szrj#else
812*38fd1498Szrj    protected:
813*38fd1498Szrj#endif
814*38fd1498Szrj      basic_streambuf(const basic_streambuf&);
815*38fd1498Szrj
816*38fd1498Szrj      basic_streambuf&
817*38fd1498Szrj      operator=(const basic_streambuf&);
818*38fd1498Szrj
819*38fd1498Szrj#if __cplusplus >= 201103L
820*38fd1498Szrj      void
821*38fd1498Szrj      swap(basic_streambuf& __sb)
822*38fd1498Szrj      {
823*38fd1498Szrj	std::swap(_M_in_beg, __sb._M_in_beg);
824*38fd1498Szrj	std::swap(_M_in_cur, __sb._M_in_cur);
825*38fd1498Szrj	std::swap(_M_in_end, __sb._M_in_end);
826*38fd1498Szrj	std::swap(_M_out_beg, __sb._M_out_beg);
827*38fd1498Szrj	std::swap(_M_out_cur, __sb._M_out_cur);
828*38fd1498Szrj	std::swap(_M_out_end, __sb._M_out_end);
829*38fd1498Szrj	std::swap(_M_buf_locale, __sb._M_buf_locale);
830*38fd1498Szrj      }
831*38fd1498Szrj#endif
832*38fd1498Szrj    };
833*38fd1498Szrj
834*38fd1498Szrj#if __cplusplus >= 201103L
835*38fd1498Szrj  template<typename _CharT, typename _Traits>
836*38fd1498Szrj    std::basic_streambuf<_CharT, _Traits>::
837*38fd1498Szrj    basic_streambuf(const basic_streambuf&) = default;
838*38fd1498Szrj
839*38fd1498Szrj  template<typename _CharT, typename _Traits>
840*38fd1498Szrj    std::basic_streambuf<_CharT, _Traits>&
841*38fd1498Szrj    std::basic_streambuf<_CharT, _Traits>::
842*38fd1498Szrj    operator=(const basic_streambuf&) = default;
843*38fd1498Szrj#endif
844*38fd1498Szrj
845*38fd1498Szrj  // Explicit specialization declarations, defined in src/streambuf.cc.
846*38fd1498Szrj  template<>
847*38fd1498Szrj    streamsize
848*38fd1498Szrj    __copy_streambufs_eof(basic_streambuf<char>* __sbin,
849*38fd1498Szrj			  basic_streambuf<char>* __sbout, bool& __ineof);
850*38fd1498Szrj#ifdef _GLIBCXX_USE_WCHAR_T
851*38fd1498Szrj  template<>
852*38fd1498Szrj    streamsize
853*38fd1498Szrj    __copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
854*38fd1498Szrj			  basic_streambuf<wchar_t>* __sbout, bool& __ineof);
855*38fd1498Szrj#endif
856*38fd1498Szrj
857*38fd1498Szrj#undef _IsUnused
858*38fd1498Szrj
859*38fd1498Szrj_GLIBCXX_END_NAMESPACE_VERSION
860*38fd1498Szrj} // namespace
861*38fd1498Szrj
862*38fd1498Szrj#include <bits/streambuf.tcc>
863*38fd1498Szrj
864*38fd1498Szrj#endif /* _GLIBCXX_STREAMBUF */
865