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