This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
[streambuf.assign]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.assign)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#assign)
#### 31.6.3.4 Protected member functions [[streambuf.protected]](streambuf.protected#streambuf.assign)
#### 31.6.3.4.1 Assignment [streambuf.assign]
[🔗](#lib:operator=,basic_streambuf)
`basic_streambuf& operator=(const basic_streambuf& rhs);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3426)
*Postconditions*:
- [(1.1)](#1.1)
eback() == rhs.eback()
- [(1.2)](#1.2)
gptr() == rhs.gptr()
- [(1.3)](#1.3)
egptr() == rhs.egptr()
- [(1.4)](#1.4)
pbase() == rhs.pbase()
- [(1.5)](#1.5)
pptr() == rhs.pptr()
- [(1.6)](#1.6)
epptr() == rhs.epptr()
- [(1.7)](#1.7)
getloc() == rhs.getloc()
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3438)
*Returns*: *this[.](#2.sentence-1)
[🔗](#lib:swap,basic_streambuf)
`void swap(basic_streambuf& rhs);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3449)
*Effects*: Swaps the data members of rhs and *this[.](#3.sentence-1)

View File

@@ -0,0 +1,59 @@
[streambuf.buffer]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.buffer)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#buffer)
#### 31.6.3.3 Public member functions [[streambuf.members]](streambuf.members#streambuf.buffer)
#### 31.6.3.3.2 Buffer management and positioning [streambuf.buffer]
[🔗](#lib:pubsetbuf,basic_streambuf)
`basic_streambuf* pubsetbuf(char_type* s, streamsize n);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3229)
*Returns*: setbuf(s, n)[.](#1.sentence-1)
[🔗](#lib:pubseekoff,basic_streambuf)
`pos_type pubseekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3242)
*Returns*: seekoff(off, way, which)[.](#2.sentence-1)
[🔗](#lib:pubseekpos,basic_streambuf)
`pos_type pubseekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3255)
*Returns*: seekpos(sp, which)[.](#3.sentence-1)
[🔗](#lib:pubsync,basic_streambuf)
`int pubsync();
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3266)
*Returns*: sync()[.](#4.sentence-1)

View File

@@ -0,0 +1,92 @@
[streambuf.cons]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.cons)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#cons)
#### 31.6.3.2 Constructors [streambuf.cons]
[🔗](#lib:basic_streambuf,constructor)
`basic_streambuf();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3112)
*Effects*: Initializes:[266](#footnote-266 "The default constructor is protected for class basic_­streambuf to assure that only objects for classes derived from this class can be constructed.")
- [(1.1)](#1.1)
all pointer member objects to null pointers,
- [(1.2)](#1.2)
thegetloc() member to a copy of the global locale,locale(),
at the time of construction[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3132)
*Remarks*: Once thegetloc() member is initialized, results of calling locale member functions,
and of members of facets so obtained, can safely be cached until the
next time the memberimbue is called[.](#2.sentence-1)
[🔗](#lib:basic_streambuf,constructor_)
`basic_streambuf(const basic_streambuf& rhs);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3149)
*Postconditions*:
- [(3.1)](#3.1)
eback() == rhs.eback()
- [(3.2)](#3.2)
gptr() == rhs.gptr()
- [(3.3)](#3.3)
egptr() == rhs.egptr()
- [(3.4)](#3.4)
pbase() == rhs.pbase()
- [(3.5)](#3.5)
pptr() == rhs.pptr()
- [(3.6)](#3.6)
epptr() == rhs.epptr()
- [(3.7)](#3.7)
getloc() == rhs.getloc()
[🔗](#lib:basic_streambuf,destructor)
`~basic_streambuf();
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3168)
*Effects*: None[.](#4.sentence-1)
[266)](#footnote-266)[266)](#footnoteref-266)
The default constructor is protected for classbasic_streambuf to assure that only objects for classes
derived from this class can be constructed[.](#footnote-266.sentence-1)

View File

@@ -0,0 +1,46 @@
[streambuf.general]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.general)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#general)
#### 31.6.3.1 General [streambuf.general]
[🔗](#lib:basic_streambuf)
namespace std {template<class charT, class traits = char_traits<charT>>class basic_streambuf {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; virtual ~basic_streambuf(); // [[streambuf.locales]](streambuf.locales "31.6.3.3.1Locales"), locales locale pubimbue(const locale& loc);
locale getloc() const; // [[streambuf.buffer]](streambuf.buffer "31.6.3.3.2Buffer management and positioning"), buffer and positioning basic_streambuf* pubsetbuf(char_type* s, streamsize n);
pos_type pubseekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out);
pos_type pubseekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out); int pubsync(); // get and put areas// [[streambuf.pub.get]](streambuf.pub.get "31.6.3.3.3Get area"), get area streamsize in_avail();
int_type snextc();
int_type sbumpc();
int_type sgetc();
streamsize sgetn(char_type* s, streamsize n); // [[streambuf.pub.pback]](streambuf.pub.pback "31.6.3.3.4Putback"), putback int_type sputbackc(char_type c);
int_type sungetc(); // [[streambuf.pub.put]](streambuf.pub.put "31.6.3.3.5Put area"), put area int_type sputc(char_type c);
streamsize sputn(const char_type* s, streamsize n); protected: basic_streambuf();
basic_streambuf(const basic_streambuf& rhs);
basic_streambuf& operator=(const basic_streambuf& rhs); void swap(basic_streambuf& rhs); // [[streambuf.get.area]](streambuf.get.area "31.6.3.4.2Get area access"), get area access char_type* eback() const;
char_type* gptr() const;
char_type* egptr() const; void gbump(int n); void setg(char_type* gbeg, char_type* gnext, char_type* gend); // [[streambuf.put.area]](streambuf.put.area "31.6.3.4.3Put area access"), put area access char_type* pbase() const;
char_type* pptr() const;
char_type* epptr() const; void pbump(int n); void setp(char_type* pbeg, char_type* pend); // [[streambuf.virtuals]](streambuf.virtuals "31.6.3.5Virtual functions"), virtual functions// [[streambuf.virt.locales]](streambuf.virt.locales "31.6.3.5.1Locales"), localesvirtual void imbue(const locale& loc); // [[streambuf.virt.buffer]](streambuf.virt.buffer "31.6.3.5.2Buffer management and positioning"), buffer management and positioningvirtual basic_streambuf* setbuf(char_type* s, streamsize n); virtual pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out); virtual int sync(); // [[streambuf.virt.get]](streambuf.virt.get "31.6.3.5.3Get area"), get areavirtual streamsize showmanyc(); virtual streamsize xsgetn(char_type* s, streamsize n); virtual int_type underflow(); virtual int_type uflow(); // [[streambuf.virt.pback]](streambuf.virt.pback "31.6.3.5.4Putback"), putbackvirtual int_type pbackfail(int_type c = traits::eof()); // [[streambuf.virt.put]](streambuf.virt.put "31.6.3.5.5Put area"), put areavirtual streamsize xsputn(const char_type* s, streamsize n); virtual int_type overflow(int_type c = traits::eof()); };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3088)
The class templatebasic_streambuf serves as a base class for deriving various[*stream buffers*](#def:stream_buffers) whose objects each control two[*character sequences*](#def:character_sequences):
- [(1.1)](#1.1)
a character[*input sequence*](#def:input_sequence);
- [(1.2)](#1.2)
a character[*output sequence*](#def:output_sequence)[.](#1.sentence-1)

View File

@@ -0,0 +1,74 @@
[streambuf.get.area]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.get.area)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#get.area)
#### 31.6.3.4 Protected member functions [[streambuf.protected]](streambuf.protected#streambuf.get.area)
#### 31.6.3.4.2 Get area access [streambuf.get.area]
[🔗](#lib:eback,basic_streambuf)
`char_type* eback() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3463)
*Returns*: The beginning pointer for the input sequence[.](#1.sentence-1)
[🔗](#lib:gptr,basic_streambuf)
`char_type* gptr() const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3474)
*Returns*: The next pointer for the input sequence[.](#2.sentence-1)
[🔗](#lib:egptr,basic_streambuf)
`char_type* egptr() const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3485)
*Returns*: The end pointer for the input sequence[.](#3.sentence-1)
[🔗](#lib:gbump,basic_streambuf)
`void gbump(int n);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3496)
*Effects*: Adds n to the next pointer for the input sequence[.](#4.sentence-1)
[🔗](#lib:setg,basic_streambuf)
`void setg(char_type* gbeg, char_type* gnext, char_type* gend);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3507)
*Preconditions*: [gbeg, gnext), [gbeg, gend), and [gnext, gend)
are all valid ranges[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3512)
*Postconditions*: gbeg == eback(),gnext == gptr(),
andgend == egptr() are all true[.](#6.sentence-1)

View File

@@ -0,0 +1,50 @@
[streambuf.locales]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.locales)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#locales)
#### 31.6.3.3 Public member functions [[streambuf.members]](streambuf.members#streambuf.locales)
#### 31.6.3.3.1 Locales [streambuf.locales]
[🔗](#lib:pubimbue,basic_streambuf)
`locale pubimbue(const locale& loc);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3183)
*Effects*: Callsimbue(loc)[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3188)
*Postconditions*: loc == getloc()[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3192)
*Returns*: Previous value ofgetloc()[.](#3.sentence-1)
[🔗](#lib:getloc,basic_streambuf)
`locale getloc() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3204)
*Returns*: Ifpubimbue() has ever been called, then the last value of loc supplied,
otherwise the current global locale,locale(),
in effect at the time of construction[.](#4.sentence-1)
If called afterpubimbue() has been called but beforepubimbue has returned (i.e., from within the call ofimbue())
then it returns the previous value[.](#4.sentence-2)

View File

@@ -0,0 +1,235 @@
[streambuf.members]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.members)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#members)
#### 31.6.3.3 Public member functions [streambuf.members]
#### [31.6.3.3.1](#streambuf.locales) Locales [[streambuf.locales]](streambuf.locales)
[🔗](#lib:pubimbue,basic_streambuf)
`locale pubimbue(const locale& loc);
`
[1](#streambuf.locales-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3183)
*Effects*: Callsimbue(loc)[.](#streambuf.locales-1.sentence-1)
[2](#streambuf.locales-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3188)
*Postconditions*: loc == getloc()[.](#streambuf.locales-2.sentence-1)
[3](#streambuf.locales-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3192)
*Returns*: Previous value ofgetloc()[.](#streambuf.locales-3.sentence-1)
[🔗](#lib:getloc,basic_streambuf)
`locale getloc() const;
`
[4](#streambuf.locales-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3204)
*Returns*: Ifpubimbue() has ever been called, then the last value of loc supplied,
otherwise the current global locale,locale(),
in effect at the time of construction[.](#streambuf.locales-4.sentence-1)
If called afterpubimbue() has been called but beforepubimbue has returned (i.e., from within the call ofimbue())
then it returns the previous value[.](#streambuf.locales-4.sentence-2)
#### [31.6.3.3.2](#streambuf.buffer) Buffer management and positioning [[streambuf.buffer]](streambuf.buffer)
[🔗](#lib:pubsetbuf,basic_streambuf)
`basic_streambuf* pubsetbuf(char_type* s, streamsize n);
`
[1](#streambuf.buffer-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3229)
*Returns*: setbuf(s, n)[.](#streambuf.buffer-1.sentence-1)
[🔗](#lib:pubseekoff,basic_streambuf)
`pos_type pubseekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[2](#streambuf.buffer-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3242)
*Returns*: seekoff(off, way, which)[.](#streambuf.buffer-2.sentence-1)
[🔗](#lib:pubseekpos,basic_streambuf)
`pos_type pubseekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[3](#streambuf.buffer-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3255)
*Returns*: seekpos(sp, which)[.](#streambuf.buffer-3.sentence-1)
[🔗](#lib:pubsync,basic_streambuf)
`int pubsync();
`
[4](#streambuf.buffer-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3266)
*Returns*: sync()[.](#streambuf.buffer-4.sentence-1)
#### [31.6.3.3.3](#streambuf.pub.get) Get area [[streambuf.pub.get]](streambuf.pub.get)
[🔗](#lib:in_avail,basic_streambuf)
`streamsize in_avail();
`
[1](#streambuf.pub.get-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3279)
*Returns*: If a read position is available, returnsegptr() - gptr()[.](#streambuf.pub.get-1.sentence-1)
Otherwise returns[showmanyc()](filebuf.virtuals#lib:basic_streambuf,showmanyc "31.10.3.5Overridden virtual functions[filebuf.virtuals]")[.](#streambuf.pub.get-1.sentence-2)
[🔗](#lib:snextc,basic_streambuf)
`int_type snextc();
`
[2](#streambuf.pub.get-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3293)
*Effects*: Callssbumpc()[.](#streambuf.pub.get-2.sentence-1)
[3](#streambuf.pub.get-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3298)
*Returns*: If that function returnstraits::eof(),
returnstraits::eof()[.](#streambuf.pub.get-3.sentence-1)
Otherwise, returnssgetc()[.](#streambuf.pub.get-3.sentence-2)
[🔗](#lib:sbumpc,basic_streambuf)
`int_type sbumpc();
`
[4](#streambuf.pub.get-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3314)
*Effects*: If the input sequence read position is not available,
returnsuflow()[.](#streambuf.pub.get-4.sentence-1)
Otherwise, returnstraits::to_int_type(*gptr()) and increments the next pointer for the input sequence[.](#streambuf.pub.get-4.sentence-2)
[🔗](#lib:sgetc,basic_streambuf)
`int_type sgetc();
`
[5](#streambuf.pub.get-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3330)
*Returns*: If the input sequence read position is not available,
returnsunderflow()[.](#streambuf.pub.get-5.sentence-1)
Otherwise, returnstraits::to_int_type(*gptr())[.](#streambuf.pub.get-5.sentence-2)
[🔗](#lib:sgetn,basic_streambuf)
`streamsize sgetn(char_type* s, streamsize n);
`
[6](#streambuf.pub.get-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3345)
*Returns*: xsgetn(s, n)[.](#streambuf.pub.get-6.sentence-1)
#### [31.6.3.3.4](#streambuf.pub.pback) Putback [[streambuf.pub.pback]](streambuf.pub.pback)
[🔗](#lib:sputbackc,basic_streambuf)
`int_type sputbackc(char_type c);
`
[1](#streambuf.pub.pback-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3358)
*Effects*: If the input sequence putback position is not available, or
iftraits::eq(c, gptr()[-1]) is false, returnspbackfail(traits::to_int_type(c))[.](#streambuf.pub.pback-1.sentence-1)
Otherwise, decrements the next pointer for the input sequence and
returnstraits::to_int_type(*gptr())[.](#streambuf.pub.pback-1.sentence-2)
[🔗](#lib:sungetc,basic_streambuf)
`int_type sungetc();
`
[2](#streambuf.pub.pback-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3376)
*Effects*: If the input sequence putback position is not available,
returnspbackfail()[.](#streambuf.pub.pback-2.sentence-1)
Otherwise, decrements the next pointer for the input sequence and
returnstraits::to_int_type(*gptr())[.](#streambuf.pub.pback-2.sentence-2)
#### [31.6.3.3.5](#streambuf.pub.put) Put area [[streambuf.pub.put]](streambuf.pub.put)
[🔗](#lib:sputc,basic_streambuf)
`int_type sputc(char_type c);
`
[1](#streambuf.pub.put-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3394)
*Effects*: If the output sequence write position is not available,
returnsoverflow(traits::to_int_type(c))[.](#streambuf.pub.put-1.sentence-1)
Otherwise, stores c at the next pointer for the output sequence,
increments the pointer, and
returnstraits::to_int_type(c)[.](#streambuf.pub.put-1.sentence-2)
[🔗](#lib:sputn,basic_streambuf)
`streamsize sputn(const char_type* s, streamsize n);
`
[2](#streambuf.pub.put-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3411)
*Returns*: xsputn(s, n)[.](#streambuf.pub.put-2.sentence-1)

View File

@@ -0,0 +1,196 @@
[streambuf.protected]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.protected)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#protected)
#### 31.6.3.4 Protected member functions [streambuf.protected]
#### [31.6.3.4.1](#streambuf.assign) Assignment [[streambuf.assign]](streambuf.assign)
[🔗](#lib:operator=,basic_streambuf)
`basic_streambuf& operator=(const basic_streambuf& rhs);
`
[1](#streambuf.assign-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3426)
*Postconditions*:
- [(1.1)](#streambuf.assign-1.1)
eback() == rhs.eback()
- [(1.2)](#streambuf.assign-1.2)
gptr() == rhs.gptr()
- [(1.3)](#streambuf.assign-1.3)
egptr() == rhs.egptr()
- [(1.4)](#streambuf.assign-1.4)
pbase() == rhs.pbase()
- [(1.5)](#streambuf.assign-1.5)
pptr() == rhs.pptr()
- [(1.6)](#streambuf.assign-1.6)
epptr() == rhs.epptr()
- [(1.7)](#streambuf.assign-1.7)
getloc() == rhs.getloc()
[2](#streambuf.assign-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3438)
*Returns*: *this[.](#streambuf.assign-2.sentence-1)
[🔗](#lib:swap,basic_streambuf)
`void swap(basic_streambuf& rhs);
`
[3](#streambuf.assign-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3449)
*Effects*: Swaps the data members of rhs and *this[.](#streambuf.assign-3.sentence-1)
#### [31.6.3.4.2](#streambuf.get.area) Get area access [[streambuf.get.area]](streambuf.get.area)
[🔗](#lib:eback,basic_streambuf)
`char_type* eback() const;
`
[1](#streambuf.get.area-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3463)
*Returns*: The beginning pointer for the input sequence[.](#streambuf.get.area-1.sentence-1)
[🔗](#lib:gptr,basic_streambuf)
`char_type* gptr() const;
`
[2](#streambuf.get.area-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3474)
*Returns*: The next pointer for the input sequence[.](#streambuf.get.area-2.sentence-1)
[🔗](#lib:egptr,basic_streambuf)
`char_type* egptr() const;
`
[3](#streambuf.get.area-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3485)
*Returns*: The end pointer for the input sequence[.](#streambuf.get.area-3.sentence-1)
[🔗](#lib:gbump,basic_streambuf)
`void gbump(int n);
`
[4](#streambuf.get.area-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3496)
*Effects*: Adds n to the next pointer for the input sequence[.](#streambuf.get.area-4.sentence-1)
[🔗](#lib:setg,basic_streambuf)
`void setg(char_type* gbeg, char_type* gnext, char_type* gend);
`
[5](#streambuf.get.area-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3507)
*Preconditions*: [gbeg, gnext), [gbeg, gend), and [gnext, gend)
are all valid ranges[.](#streambuf.get.area-5.sentence-1)
[6](#streambuf.get.area-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3512)
*Postconditions*: gbeg == eback(),gnext == gptr(),
andgend == egptr() are all true[.](#streambuf.get.area-6.sentence-1)
#### [31.6.3.4.3](#streambuf.put.area) Put area access [[streambuf.put.area]](streambuf.put.area)
[🔗](#lib:pbase,basic_streambuf)
`char_type* pbase() const;
`
[1](#streambuf.put.area-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3528)
*Returns*: The beginning pointer for the output sequence[.](#streambuf.put.area-1.sentence-1)
[🔗](#lib:pptr,basic_streambuf)
`char_type* pptr() const;
`
[2](#streambuf.put.area-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3539)
*Returns*: The next pointer for the output sequence[.](#streambuf.put.area-2.sentence-1)
[🔗](#lib:epptr,basic_streambuf)
`char_type* epptr() const;
`
[3](#streambuf.put.area-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3550)
*Returns*: The end pointer for the output sequence[.](#streambuf.put.area-3.sentence-1)
[🔗](#lib:pbump,basic_streambuf)
`void pbump(int n);
`
[4](#streambuf.put.area-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3561)
*Effects*: Adds n to the next pointer for the output sequence[.](#streambuf.put.area-4.sentence-1)
[🔗](#lib:setp,basic_streambuf)
`void setp(char_type* pbeg, char_type* pend);
`
[5](#streambuf.put.area-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3572)
*Preconditions*: [pbeg, pend) is a valid range[.](#streambuf.put.area-5.sentence-1)
[6](#streambuf.put.area-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3576)
*Postconditions*: pbeg == pbase(),pbeg == pptr(),
andpend == epptr() are all true[.](#streambuf.put.area-6.sentence-1)

View File

@@ -0,0 +1,83 @@
[streambuf.pub.get]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.pub.get)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#pub.get)
#### 31.6.3.3 Public member functions [[streambuf.members]](streambuf.members#streambuf.pub.get)
#### 31.6.3.3.3 Get area [streambuf.pub.get]
[🔗](#lib:in_avail,basic_streambuf)
`streamsize in_avail();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3279)
*Returns*: If a read position is available, returnsegptr() - gptr()[.](#1.sentence-1)
Otherwise returns[showmanyc()](filebuf.virtuals#lib:basic_streambuf,showmanyc "31.10.3.5Overridden virtual functions[filebuf.virtuals]")[.](#1.sentence-2)
[🔗](#lib:snextc,basic_streambuf)
`int_type snextc();
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3293)
*Effects*: Callssbumpc()[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3298)
*Returns*: If that function returnstraits::eof(),
returnstraits::eof()[.](#3.sentence-1)
Otherwise, returnssgetc()[.](#3.sentence-2)
[🔗](#lib:sbumpc,basic_streambuf)
`int_type sbumpc();
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3314)
*Effects*: If the input sequence read position is not available,
returnsuflow()[.](#4.sentence-1)
Otherwise, returnstraits::to_int_type(*gptr()) and increments the next pointer for the input sequence[.](#4.sentence-2)
[🔗](#lib:sgetc,basic_streambuf)
`int_type sgetc();
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3330)
*Returns*: If the input sequence read position is not available,
returnsunderflow()[.](#5.sentence-1)
Otherwise, returnstraits::to_int_type(*gptr())[.](#5.sentence-2)
[🔗](#lib:sgetn,basic_streambuf)
`streamsize sgetn(char_type* s, streamsize n);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3345)
*Returns*: xsgetn(s, n)[.](#6.sentence-1)

View File

@@ -0,0 +1,41 @@
[streambuf.pub.pback]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.pub.pback)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#pub.pback)
#### 31.6.3.3 Public member functions [[streambuf.members]](streambuf.members#streambuf.pub.pback)
#### 31.6.3.3.4 Putback [streambuf.pub.pback]
[🔗](#lib:sputbackc,basic_streambuf)
`int_type sputbackc(char_type c);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3358)
*Effects*: If the input sequence putback position is not available, or
iftraits::eq(c, gptr()[-1]) is false, returnspbackfail(traits::to_int_type(c))[.](#1.sentence-1)
Otherwise, decrements the next pointer for the input sequence and
returnstraits::to_int_type(*gptr())[.](#1.sentence-2)
[🔗](#lib:sungetc,basic_streambuf)
`int_type sungetc();
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3376)
*Effects*: If the input sequence putback position is not available,
returnspbackfail()[.](#2.sentence-1)
Otherwise, decrements the next pointer for the input sequence and
returnstraits::to_int_type(*gptr())[.](#2.sentence-2)

View File

@@ -0,0 +1,38 @@
[streambuf.pub.put]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.pub.put)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#pub.put)
#### 31.6.3.3 Public member functions [[streambuf.members]](streambuf.members#streambuf.pub.put)
#### 31.6.3.3.5 Put area [streambuf.pub.put]
[🔗](#lib:sputc,basic_streambuf)
`int_type sputc(char_type c);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3394)
*Effects*: If the output sequence write position is not available,
returnsoverflow(traits::to_int_type(c))[.](#1.sentence-1)
Otherwise, stores c at the next pointer for the output sequence,
increments the pointer, and
returnstraits::to_int_type(c)[.](#1.sentence-2)
[🔗](#lib:sputn,basic_streambuf)
`streamsize sputn(const char_type* s, streamsize n);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3411)
*Returns*: xsputn(s, n)[.](#2.sentence-1)

View File

@@ -0,0 +1,73 @@
[streambuf.put.area]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.put.area)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#put.area)
#### 31.6.3.4 Protected member functions [[streambuf.protected]](streambuf.protected#streambuf.put.area)
#### 31.6.3.4.3 Put area access [streambuf.put.area]
[🔗](#lib:pbase,basic_streambuf)
`char_type* pbase() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3528)
*Returns*: The beginning pointer for the output sequence[.](#1.sentence-1)
[🔗](#lib:pptr,basic_streambuf)
`char_type* pptr() const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3539)
*Returns*: The next pointer for the output sequence[.](#2.sentence-1)
[🔗](#lib:epptr,basic_streambuf)
`char_type* epptr() const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3550)
*Returns*: The end pointer for the output sequence[.](#3.sentence-1)
[🔗](#lib:pbump,basic_streambuf)
`void pbump(int n);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3561)
*Effects*: Adds n to the next pointer for the output sequence[.](#4.sentence-1)
[🔗](#lib:setp,basic_streambuf)
`void setp(char_type* pbeg, char_type* pend);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3572)
*Preconditions*: [pbeg, pend) is a valid range[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3576)
*Postconditions*: pbeg == pbase(),pbeg == pptr(),
andpend == epptr() are all true[.](#6.sentence-1)

109
cppdraft/streambuf/reqts.md Normal file
View File

@@ -0,0 +1,109 @@
[streambuf.reqts]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.reqts)
### 31.6.2 Stream buffer requirements [streambuf.reqts]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2891)
Stream buffers can impose various constraints on the sequences they control[.](#1.sentence-1)
Some constraints are:
- [(1.1)](#1.1)
The controlled input sequence can be not readable[.](#1.1.sentence-1)
- [(1.2)](#1.2)
The controlled output sequence can be not writable[.](#1.2.sentence-1)
- [(1.3)](#1.3)
The controlled sequences can be associated with the contents of other
representations for character sequences, such as external files[.](#1.3.sentence-1)
- [(1.4)](#1.4)
The controlled sequences can support operations*directly* to or from associated sequences[.](#1.4.sentence-1)
- [(1.5)](#1.5)
The controlled sequences can impose limitations on how the program can
read characters from a sequence,
write characters to a sequence,
put characters back into an input sequence, or
alter the stream position[.](#1.5.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2914)
Each sequence is characterized by three pointers which, if non-null,
all point into the samecharT array object[.](#2.sentence-1)
The array object represents, at any moment,
a (sub)sequence of characters from the sequence[.](#2.sentence-2)
Operations performed on a sequence alter the values stored in these pointers,
perform reads and writes directly to or from associated sequences, and
alter “the stream position” and conversion state as needed to
maintain this subsequence relationship[.](#2.sentence-3)
The three pointers are:
- [(2.1)](#2.1)
the[*beginning pointer*](#def:beginning_pointer),
or lowest element address in the array
(called xbeg here);
- [(2.2)](#2.2)
the[*next pointer*](#def:next_pointer),
or next element address that is a current
candidate for reading or writing (called xnext here);
- [(2.3)](#2.3)
the[*end pointer*](#def:end_pointer),
or first element address beyond the end of
the array (called xend here)[.](#2.sentence-4)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2944)
The following semantic constraints shall always apply for any set of
three pointers for a sequence, using the pointer names given immediately above:
- [(3.1)](#3.1)
If xnext is not a null pointer, thenxbeg and xend shall also be non-null pointers
into the samecharT array, as described above; otherwise, xbeg andxend shall also be null[.](#3.1.sentence-1)
- [(3.2)](#3.2)
If xnext is not a null pointer andxnext < xend for an output sequence, then a[*write position*](#def:write_position) is available[.](#3.2.sentence-1)
In this case,*xnext shall be assignable as the
next element to write
(to put, or to store a character value, into the sequence)[.](#3.2.sentence-2)
- [(3.3)](#3.3)
If xnext is not a null pointer andxbeg < xnext for an input sequence,
then a[*putback position*](#def:putback_position) is available[.](#3.3.sentence-1)
In this case,xnext[-1] shall have a defined value and is the next (preceding) element
to store a character that is put back into the input sequence[.](#3.3.sentence-2)
- [(3.4)](#3.4)
If xnext is not a null pointer andxnext < xend for an input sequence,
then a[*read position*](#def:read_position) is available[.](#3.4.sentence-1)
In this case,*xnext shall have a defined value
and is the next element to read
(to get, or to obtain a character value, from the sequence)[.](#3.4.sentence-2)

17
cppdraft/streambuf/syn.md Normal file
View File

@@ -0,0 +1,17 @@
[streambuf.syn]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.syn)
### 31.6.1 Header <streambuf> synopsis [streambuf.syn]
[🔗](#header:%3cstreambuf%3e)
namespace std {// [[streambuf]](streambuf "31.6.3Class template basic_­streambuf"), class template basic_streambuftemplate<class charT, class traits = char_traits<charT>>class basic_streambuf; using streambuf = basic_streambuf<char>; using wstreambuf = basic_streambuf<wchar_t>;}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L2884)
The header [<streambuf>](#header:%3cstreambuf%3e "31.6.1Header <streambuf> synopsis[streambuf.syn]") defines types that control input from and output to*character* sequences[.](#1.sentence-1)

View File

@@ -0,0 +1,102 @@
[streambuf.virt.buffer]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.virt.buffer)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#virt.buffer)
#### 31.6.3.5 Virtual functions [[streambuf.virtuals]](streambuf.virtuals#streambuf.virt.buffer)
#### 31.6.3.5.2 Buffer management and positioning [streambuf.virt.buffer]
[🔗](#lib:setbuf,basic_streambuf)
`basic_streambuf* setbuf(char_type* s, streamsize n);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3619)
*Effects*: Influences stream buffering in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf.virtuals]](stringbuf.virtuals "31.8.2.5Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3626)
*Default behavior*: Does nothing[.](#2.sentence-1)
Returnsthis[.](#2.sentence-2)
[🔗](#lib:seekoff,basic_streambuf)
`pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3641)
*Effects*: Alters the stream positions within one or more of
the controlled sequences in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf.virtuals]](stringbuf.virtuals "31.8.2.5Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3649)
*Default behavior*: Returnspos_type(off_type(-1))[.](#4.sentence-1)
[🔗](#lib:seekpos,basic_streambuf)
`pos_type seekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3663)
*Effects*: Alters the stream positions within one or more of
the controlled sequences in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf]](stringbuf "31.8.2Class template basic_­stringbuf"), [[filebuf]](filebuf "31.10.3Class template basic_­filebuf"))[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3671)
*Default behavior*: Returnspos_type(off_type(-1))[.](#6.sentence-1)
[🔗](#lib:sync,basic_streambuf)
`int sync();
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3683)
*Effects*: Synchronizes the controlled sequences with the arrays[.](#7.sentence-1)
That is, ifpbase() is non-null the characters betweenpbase() andpptr() are written to the controlled sequence[.](#7.sentence-2)
The pointers may then be reset as appropriate[.](#7.sentence-3)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3695)
*Returns*: -1 on failure[.](#8.sentence-1)
What constitutes failure is determined by each derived class ([[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#8.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3700)
*Default behavior*: Returns zero[.](#9.sentence-1)

View File

@@ -0,0 +1,204 @@
[streambuf.virt.get]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.virt.get)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#virt.get)
#### 31.6.3.5 Virtual functions [[streambuf.virtuals]](streambuf.virtuals#streambuf.virt.get)
#### 31.6.3.5.3 Get area [streambuf.virt.get]
[🔗](#lib:showmanyc,basic_streambuf)
`streamsize showmanyc();[267](#footnote-267 "The morphemes of showmanyc are “es-how-many-see”, not “show-manic”.")
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3716)
*Returns*: An estimate of the number of
characters available in the sequence, or −1[.](#1.sentence-1)
If it returns
a positive value, then successive calls tounderflow() will not returntraits::eof() until at least that number of characters have been
extracted from the stream[.](#1.sentence-2)
Ifshowmanyc() returns −1, then calls tounderflow() oruflow() will fail[.](#1.sentence-3)[268](#footnote-268 "underflow or uflow can fail by throwing an exception prematurely. The intention is not only that the calls will not return eof() but that they will return “immediately”.")
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3744)
*Default behavior*: Returns zero[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3748)
*Remarks*: Usestraits::eof()[.](#3.sentence-1)
[🔗](#lib:xsgetn,basic_streambuf)
`streamsize xsgetn(char_type* s, streamsize n);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3760)
*Effects*: Assigns up to n characters to successive elements of
the array whose first element is designated by s[.](#4.sentence-1)
The characters assigned are read from the input sequence as if
by repeated calls tosbumpc()[.](#4.sentence-2)
Assigning stops when either n characters
have been assigned or a call tosbumpc() would returntraits::eof()[.](#4.sentence-3)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3773)
*Returns*: The number of characters assigned[.](#5.sentence-1)[269](#footnote-269 "Classes derived from basic_­streambuf can provide more efficient ways to implement xsgetn() and xsputn() by overriding these definitions from the base class.")
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3786)
*Remarks*: Usestraits::eof()[.](#6.sentence-1)
[🔗](#lib:underflow,basic_streambuf)
`int_type underflow();
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3798)
The[*pending sequence*](#def:pending_sequence) of characters is defined as the concatenation of
- [(7.1)](#7.1)
the empty sequence if gptr() is null, otherwise the
characters in
[gptr(), egptr()),
followed by
- [(7.2)](#7.2)
some (possibly empty) sequence of characters read from the input sequence[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3811)
The[*result character*](#def:result_character) is
the first character of the pending sequence if it is non-empty,
otherwise
the next character that would be read from the input sequence[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3819)
The[*backup sequence*](#def:backup_sequence) is the empty sequence if eback() is null, otherwise the
characters in
[eback(), gptr())[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3826)
*Effects*: The function sets up thegptr() andegptr() such that
if the pending sequence is non-empty, thenegptr() is non-null and
the characters in [gptr(), egptr()) are
the characters in the pending sequence,
otherwise
either gptr() is null orgptr() == egptr()[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3843)
Ifeback() andgptr() are non-null then the function is not constrained as to their contents, but the “usual backup condition” is that either
- [(11.1)](#11.1)
the backup sequence contains at leastgptr() - eback() characters, in which case the characters in
[eback(), gptr())
agree with the lastgptr() - eback() characters of the backup sequence, or
- [(11.2)](#11.2)
the characters in [gptr() - n, gptr())
agree with the backup sequence (where n is the length of the backup sequence)[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3863)
*Returns*: traits::to_int_type(c),
where c is the first*character* of the[*pending sequence*](#def:pending_sequence),
without moving the input sequence position past it[.](#12.sentence-1)
If the pending sequence is null then the function returnstraits::eof() to indicate failure[.](#12.sentence-2)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3875)
*Default behavior*: Returnstraits::eof()[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3880)
*Remarks*: The public members ofbasic_streambuf call this virtual function only ifgptr() is null orgptr() >= egptr()[.](#14.sentence-1)
[🔗](#lib:uflow,basic_streambuf)
`int_type uflow();
`
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3896)
*Preconditions*: The constraints are the same as forunderflow(),
except that the result character is transferred from the pending
sequence to the backup sequence, and the pending sequence is not empty before the transfer[.](#15.sentence-1)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3903)
*Default behavior*: Callsunderflow()[.](#16.sentence-1)
Ifunderflow() returnstraits::eof(),
returnstraits::eof()[.](#16.sentence-2)
Otherwise, returns the value oftraits::to_int_type(*gptr()) and increments the value of the next pointer for the input sequence[.](#16.sentence-3)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3917)
*Returns*: traits::eof() to indicate failure[.](#17.sentence-1)
[267)](#footnote-267)[267)](#footnoteref-267)
The morphemes of showmanyc are “es-how-many-see”, not “show-manic”[.](#footnote-267.sentence-1)
[268)](#footnote-268)[268)](#footnoteref-268)
underflow oruflow can fail by throwing an exception prematurely[.](#footnote-268.sentence-1)
The intention is not only that the calls will not returneof() but that they will return “immediately”[.](#footnote-268.sentence-2)
[269)](#footnote-269)[269)](#footnoteref-269)
Classes derived frombasic_streambuf can provide more efficient ways to implementxsgetn() andxsputn() by overriding these definitions from the base class[.](#footnote-269.sentence-1)

View File

@@ -0,0 +1,39 @@
[streambuf.virt.locales]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.virt.locales)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#virt.locales)
#### 31.6.3.5 Virtual functions [[streambuf.virtuals]](streambuf.virtuals#streambuf.virt.locales)
#### 31.6.3.5.1 Locales [streambuf.virt.locales]
[🔗](#lib:imbue,basic_streambuf)
`void imbue(const locale&);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3594)
*Effects*: Change any translations based on locale[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3598)
*Remarks*: Allows the derived class to be informed of changes in locale at the
time they occur[.](#2.sentence-1)
Between invocations of this function a class derived
from streambuf can safely cache results of calls to locale functions
and to members of facets so obtained[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3606)
*Default behavior*: Does nothing[.](#3.sentence-1)

View File

@@ -0,0 +1,72 @@
[streambuf.virt.pback]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.virt.pback)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#virt.pback)
#### 31.6.3.5 Virtual functions [[streambuf.virtuals]](streambuf.virtuals#streambuf.virt.pback)
#### 31.6.3.5.4 Putback [streambuf.virt.pback]
[🔗](#lib:pbackfail,basic_streambuf)
`int_type pbackfail(int_type c = traits::eof());
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3931)
The[*pending sequence*](#def:pending_sequence) is defined as forunderflow(),
with the modifications that
- [(1.1)](#1.1)
Iftraits::eq_int_type(c, traits::eof()) returnstrue,
then the input sequence is backed up one character before the pending sequence is determined[.](#1.1.sentence-1)
- [(1.2)](#1.2)
Iftraits::eq_int_type(c, traits::eof()) returns false, then c is prepended[.](#1.2.sentence-1)
Whether the input sequence is backed up or modified in any other way is unspecified[.](#1.2.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3951)
*Postconditions*: On return, the constraints ofgptr(),eback(),
andpptr() are the same as forunderflow()[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3961)
*Returns*: traits::eof() to indicate failure[.](#3.sentence-1)
Failure may occur because the input sequence could not be backed up, or if for some
other reason the pointers cannot be set consistent with the constraints[.](#3.sentence-2)
pbackfail() is called only when put back has really failed[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3970)
Returns some value other thantraits::eof() to indicate success[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3975)
*Default behavior*: Returnstraits::eof()[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3980)
*Remarks*: The public functions ofbasic_streambuf call this virtual function only whengptr() is null,gptr() == eback(),
ortraits::eq(traits::to_char_type(c), gptr()[-1]) returnsfalse[.](#6.sentence-1)
Other calls shall also satisfy that constraint[.](#6.sentence-2)

View File

@@ -0,0 +1,121 @@
[streambuf.virt.put]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.virt.put)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#virt.put)
#### 31.6.3.5 Virtual functions [[streambuf.virtuals]](streambuf.virtuals#streambuf.virt.put)
#### 31.6.3.5.5 Put area [streambuf.virt.put]
[🔗](#lib:xsputn,basic_streambuf)
`streamsize xsputn(const char_type* s, streamsize n);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4003)
*Effects*: Writes up to n characters to the output sequence as if
by repeated calls tosputc(c)[.](#1.sentence-1)
The characters written are obtained from successive elements of
the array whose first element is designated by s[.](#1.sentence-2)
Writing stops when either n characters have been written or
a call tosputc(c) would returntraits::eof()[.](#1.sentence-3)
It is unspecified whether the function calls overflow() when pptr() == epptr() becomes true or whether it achieves the same effects by other means[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4017)
*Returns*: The number of characters written[.](#2.sentence-1)
[🔗](#lib:overflow,basic_streambuf)
`int_type overflow(int_type c = traits::eof());
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4028)
*Effects*: Consumes some initial subsequence of the characters of the[*pending sequence*](#def:pending_sequence)[.](#3.sentence-1)
The pending sequence is defined as the concatenation of
- [(3.1)](#3.1)
the empty sequence if pbase() is null, otherwise thepptr() - pbase() characters beginning atpbase(), followed by
- [(3.2)](#3.2)
the empty sequence
iftraits::eq_int_type(c, traits::eof()) returnstrue, otherwise the sequence consisting of c[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4047)
*Preconditions*: Every overriding definition of this virtual function
obeys the following constraints:
- [(4.1)](#4.1)
The effect of consuming a character on the associated output sequence is
specified[.](#4.1.sentence-1)[270](#footnote-270 "That is, for each class derived from a specialization of basic_­streambuf in this Clause ([stringbuf], [filebuf]), a specification of how consuming a character effects the associated output sequence is given. There is no requirement on a program-defined class.")
- [(4.2)](#4.2)
Letr be the number of characters in the pending sequence not consumed[.](#4.2.sentence-1)
Ifr is nonzero thenpbase() andpptr() are set so that:pptr() - pbase() == r and the r characters starting atpbase() are the associated output stream[.](#4.2.sentence-2)
In case r is zero (all characters of the pending sequence have been consumed)
then eitherpbase() is set tonullptr,
orpbase() andpptr() are both set to the same non-null value[.](#4.2.sentence-3)
- [(4.3)](#4.3)
The function may fail if either
appending some character to the associated output stream fails or
if it is unable to establishpbase() andpptr() according to the above rules[.](#4.3.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4097)
*Returns*: traits::eof() or throws an exception
if the function fails[.](#5.sentence-1)
Otherwise,
returns some value other thantraits::eof() to indicate success[.](#5.sentence-2)[271](#footnote-271 "Typically, overflow returns c to indicate success, except when traits::eq_­int_­type(c, traits::eof()) returns true, in which case it returns traits::not_­eof(c).")
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4118)
*Default behavior*: Returnstraits::eof()[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4123)
*Remarks*: The member functionssputc() andsputn() call this function in case that
no room can be found in the put buffer enough to accommodate the
argument character sequence[.](#7.sentence-1)
[270)](#footnote-270)[270)](#footnoteref-270)
That is, for each class derived from a specialization ofbasic_streambuf in this Clause ([[stringbuf]](stringbuf "31.8.2Class template basic_­stringbuf"), [[filebuf]](filebuf "31.10.3Class template basic_­filebuf")),
a specification of how consuming a character effects the associated output sequence is given[.](#footnote-270.sentence-1)
There is no requirement on a program-defined class[.](#footnote-270.sentence-2)
[271)](#footnote-271)[271)](#footnoteref-271)
Typically,overflow returns c to indicate success, except whentraits::eq_int_type(c, traits::eof()) returnstrue,
in which case it returnstraits::not_eof(c)[.](#footnote-271.sentence-1)

View File

@@ -0,0 +1,502 @@
[streambuf.virtuals]
# 31 Input/output library [[input.output]](./#input.output)
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf.virtuals)
### 31.6.3 Class template basic_streambuf [[streambuf]](streambuf#virtuals)
#### 31.6.3.5 Virtual functions [streambuf.virtuals]
#### [31.6.3.5.1](#streambuf.virt.locales) Locales [[streambuf.virt.locales]](streambuf.virt.locales)
[🔗](#lib:imbue,basic_streambuf)
`void imbue(const locale&);
`
[1](#streambuf.virt.locales-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3594)
*Effects*: Change any translations based on locale[.](#streambuf.virt.locales-1.sentence-1)
[2](#streambuf.virt.locales-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3598)
*Remarks*: Allows the derived class to be informed of changes in locale at the
time they occur[.](#streambuf.virt.locales-2.sentence-1)
Between invocations of this function a class derived
from streambuf can safely cache results of calls to locale functions
and to members of facets so obtained[.](#streambuf.virt.locales-2.sentence-2)
[3](#streambuf.virt.locales-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3606)
*Default behavior*: Does nothing[.](#streambuf.virt.locales-3.sentence-1)
#### [31.6.3.5.2](#streambuf.virt.buffer) Buffer management and positioning [[streambuf.virt.buffer]](streambuf.virt.buffer)
[🔗](#lib:setbuf,basic_streambuf)
`basic_streambuf* setbuf(char_type* s, streamsize n);
`
[1](#streambuf.virt.buffer-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3619)
*Effects*: Influences stream buffering in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf.virtuals]](stringbuf.virtuals "31.8.2.5Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#streambuf.virt.buffer-1.sentence-1)
[2](#streambuf.virt.buffer-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3626)
*Default behavior*: Does nothing[.](#streambuf.virt.buffer-2.sentence-1)
Returnsthis[.](#streambuf.virt.buffer-2.sentence-2)
[🔗](#lib:seekoff,basic_streambuf)
`pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[3](#streambuf.virt.buffer-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3641)
*Effects*: Alters the stream positions within one or more of
the controlled sequences in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf.virtuals]](stringbuf.virtuals "31.8.2.5Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#streambuf.virt.buffer-3.sentence-1)
[4](#streambuf.virt.buffer-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3649)
*Default behavior*: Returnspos_type(off_type(-1))[.](#streambuf.virt.buffer-4.sentence-1)
[🔗](#lib:seekpos,basic_streambuf)
`pos_type seekpos(pos_type sp,
ios_base::openmode which
= ios_base::in | ios_base::out);
`
[5](#streambuf.virt.buffer-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3663)
*Effects*: Alters the stream positions within one or more of
the controlled sequences in a way that is defined separately for each class
derived frombasic_streambuf in this Clause ([[stringbuf]](stringbuf "31.8.2Class template basic_­stringbuf"), [[filebuf]](filebuf "31.10.3Class template basic_­filebuf"))[.](#streambuf.virt.buffer-5.sentence-1)
[6](#streambuf.virt.buffer-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3671)
*Default behavior*: Returnspos_type(off_type(-1))[.](#streambuf.virt.buffer-6.sentence-1)
[🔗](#lib:sync,basic_streambuf)
`int sync();
`
[7](#streambuf.virt.buffer-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3683)
*Effects*: Synchronizes the controlled sequences with the arrays[.](#streambuf.virt.buffer-7.sentence-1)
That is, ifpbase() is non-null the characters betweenpbase() andpptr() are written to the controlled sequence[.](#streambuf.virt.buffer-7.sentence-2)
The pointers may then be reset as appropriate[.](#streambuf.virt.buffer-7.sentence-3)
[8](#streambuf.virt.buffer-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3695)
*Returns*: -1 on failure[.](#streambuf.virt.buffer-8.sentence-1)
What constitutes failure is determined by each derived class ([[filebuf.virtuals]](filebuf.virtuals "31.10.3.5Overridden virtual functions"))[.](#streambuf.virt.buffer-8.sentence-2)
[9](#streambuf.virt.buffer-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3700)
*Default behavior*: Returns zero[.](#streambuf.virt.buffer-9.sentence-1)
#### [31.6.3.5.3](#streambuf.virt.get) Get area [[streambuf.virt.get]](streambuf.virt.get)
[🔗](#lib:showmanyc,basic_streambuf)
`streamsize showmanyc();[267](#footnote-267 "The morphemes of showmanyc are “es-how-many-see”, not “show-manic”.")
`
[1](#streambuf.virt.get-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3716)
*Returns*: An estimate of the number of
characters available in the sequence, or −1[.](#streambuf.virt.get-1.sentence-1)
If it returns
a positive value, then successive calls tounderflow() will not returntraits::eof() until at least that number of characters have been
extracted from the stream[.](#streambuf.virt.get-1.sentence-2)
Ifshowmanyc() returns −1, then calls tounderflow() oruflow() will fail[.](#streambuf.virt.get-1.sentence-3)[268](#footnote-268 "underflow or uflow can fail by throwing an exception prematurely. The intention is not only that the calls will not return eof() but that they will return “immediately”.")
[2](#streambuf.virt.get-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3744)
*Default behavior*: Returns zero[.](#streambuf.virt.get-2.sentence-1)
[3](#streambuf.virt.get-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3748)
*Remarks*: Usestraits::eof()[.](#streambuf.virt.get-3.sentence-1)
[🔗](#lib:xsgetn,basic_streambuf)
`streamsize xsgetn(char_type* s, streamsize n);
`
[4](#streambuf.virt.get-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3760)
*Effects*: Assigns up to n characters to successive elements of
the array whose first element is designated by s[.](#streambuf.virt.get-4.sentence-1)
The characters assigned are read from the input sequence as if
by repeated calls tosbumpc()[.](#streambuf.virt.get-4.sentence-2)
Assigning stops when either n characters
have been assigned or a call tosbumpc() would returntraits::eof()[.](#streambuf.virt.get-4.sentence-3)
[5](#streambuf.virt.get-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3773)
*Returns*: The number of characters assigned[.](#streambuf.virt.get-5.sentence-1)[269](#footnote-269 "Classes derived from basic_­streambuf can provide more efficient ways to implement xsgetn() and xsputn() by overriding these definitions from the base class.")
[6](#streambuf.virt.get-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3786)
*Remarks*: Usestraits::eof()[.](#streambuf.virt.get-6.sentence-1)
[🔗](#lib:underflow,basic_streambuf)
`int_type underflow();
`
[7](#streambuf.virt.get-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3798)
The[*pending sequence*](#def:pending_sequence) of characters is defined as the concatenation of
- [(7.1)](#streambuf.virt.get-7.1)
the empty sequence if gptr() is null, otherwise the
characters in
[gptr(), egptr()),
followed by
- [(7.2)](#streambuf.virt.get-7.2)
some (possibly empty) sequence of characters read from the input sequence[.](#streambuf.virt.get-7.sentence-1)
[8](#streambuf.virt.get-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3811)
The[*result character*](#def:result_character) is
the first character of the pending sequence if it is non-empty,
otherwise
the next character that would be read from the input sequence[.](#streambuf.virt.get-8.sentence-1)
[9](#streambuf.virt.get-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3819)
The[*backup sequence*](#def:backup_sequence) is the empty sequence if eback() is null, otherwise the
characters in
[eback(), gptr())[.](#streambuf.virt.get-9.sentence-1)
[10](#streambuf.virt.get-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3826)
*Effects*: The function sets up thegptr() andegptr() such that
if the pending sequence is non-empty, thenegptr() is non-null and
the characters in [gptr(), egptr()) are
the characters in the pending sequence,
otherwise
either gptr() is null orgptr() == egptr()[.](#streambuf.virt.get-10.sentence-1)
[11](#streambuf.virt.get-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3843)
Ifeback() andgptr() are non-null then the function is not constrained as to their contents, but the “usual backup condition” is that either
- [(11.1)](#streambuf.virt.get-11.1)
the backup sequence contains at leastgptr() - eback() characters, in which case the characters in
[eback(), gptr())
agree with the lastgptr() - eback() characters of the backup sequence, or
- [(11.2)](#streambuf.virt.get-11.2)
the characters in [gptr() - n, gptr())
agree with the backup sequence (where n is the length of the backup sequence)[.](#streambuf.virt.get-11.sentence-1)
[12](#streambuf.virt.get-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3863)
*Returns*: traits::to_int_type(c),
where c is the first*character* of the[*pending sequence*](#def:pending_sequence),
without moving the input sequence position past it[.](#streambuf.virt.get-12.sentence-1)
If the pending sequence is null then the function returnstraits::eof() to indicate failure[.](#streambuf.virt.get-12.sentence-2)
[13](#streambuf.virt.get-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3875)
*Default behavior*: Returnstraits::eof()[.](#streambuf.virt.get-13.sentence-1)
[14](#streambuf.virt.get-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3880)
*Remarks*: The public members ofbasic_streambuf call this virtual function only ifgptr() is null orgptr() >= egptr()[.](#streambuf.virt.get-14.sentence-1)
[🔗](#lib:uflow,basic_streambuf)
`int_type uflow();
`
[15](#streambuf.virt.get-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3896)
*Preconditions*: The constraints are the same as forunderflow(),
except that the result character is transferred from the pending
sequence to the backup sequence, and the pending sequence is not empty before the transfer[.](#streambuf.virt.get-15.sentence-1)
[16](#streambuf.virt.get-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3903)
*Default behavior*: Callsunderflow()[.](#streambuf.virt.get-16.sentence-1)
Ifunderflow() returnstraits::eof(),
returnstraits::eof()[.](#streambuf.virt.get-16.sentence-2)
Otherwise, returns the value oftraits::to_int_type(*gptr()) and increments the value of the next pointer for the input sequence[.](#streambuf.virt.get-16.sentence-3)
[17](#streambuf.virt.get-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3917)
*Returns*: traits::eof() to indicate failure[.](#streambuf.virt.get-17.sentence-1)
[267)](#footnote-267)[267)](#footnoteref-267)
The morphemes of showmanyc are “es-how-many-see”, not “show-manic”[.](#footnote-267.sentence-1)
[268)](#footnote-268)[268)](#footnoteref-268)
underflow oruflow can fail by throwing an exception prematurely[.](#footnote-268.sentence-1)
The intention is not only that the calls will not returneof() but that they will return “immediately”[.](#footnote-268.sentence-2)
[269)](#footnote-269)[269)](#footnoteref-269)
Classes derived frombasic_streambuf can provide more efficient ways to implementxsgetn() andxsputn() by overriding these definitions from the base class[.](#footnote-269.sentence-1)
#### [31.6.3.5.4](#streambuf.virt.pback) Putback [[streambuf.virt.pback]](streambuf.virt.pback)
[🔗](#lib:pbackfail,basic_streambuf)
`int_type pbackfail(int_type c = traits::eof());
`
[1](#streambuf.virt.pback-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3931)
The[*pending sequence*](#def:pending_sequence) is defined as forunderflow(),
with the modifications that
- [(1.1)](#streambuf.virt.pback-1.1)
Iftraits::eq_int_type(c, traits::eof()) returnstrue,
then the input sequence is backed up one character before the pending sequence is determined[.](#streambuf.virt.pback-1.1.sentence-1)
- [(1.2)](#streambuf.virt.pback-1.2)
Iftraits::eq_int_type(c, traits::eof()) returns false, then c is prepended[.](#streambuf.virt.pback-1.2.sentence-1)
Whether the input sequence is backed up or modified in any other way is unspecified[.](#streambuf.virt.pback-1.2.sentence-2)
[2](#streambuf.virt.pback-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3951)
*Postconditions*: On return, the constraints ofgptr(),eback(),
andpptr() are the same as forunderflow()[.](#streambuf.virt.pback-2.sentence-1)
[3](#streambuf.virt.pback-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3961)
*Returns*: traits::eof() to indicate failure[.](#streambuf.virt.pback-3.sentence-1)
Failure may occur because the input sequence could not be backed up, or if for some
other reason the pointers cannot be set consistent with the constraints[.](#streambuf.virt.pback-3.sentence-2)
pbackfail() is called only when put back has really failed[.](#streambuf.virt.pback-3.sentence-3)
[4](#streambuf.virt.pback-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3970)
Returns some value other thantraits::eof() to indicate success[.](#streambuf.virt.pback-4.sentence-1)
[5](#streambuf.virt.pback-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3975)
*Default behavior*: Returnstraits::eof()[.](#streambuf.virt.pback-5.sentence-1)
[6](#streambuf.virt.pback-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3980)
*Remarks*: The public functions ofbasic_streambuf call this virtual function only whengptr() is null,gptr() == eback(),
ortraits::eq(traits::to_char_type(c), gptr()[-1]) returnsfalse[.](#streambuf.virt.pback-6.sentence-1)
Other calls shall also satisfy that constraint[.](#streambuf.virt.pback-6.sentence-2)
#### [31.6.3.5.5](#streambuf.virt.put) Put area [[streambuf.virt.put]](streambuf.virt.put)
[🔗](#lib:xsputn,basic_streambuf)
`streamsize xsputn(const char_type* s, streamsize n);
`
[1](#streambuf.virt.put-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4003)
*Effects*: Writes up to n characters to the output sequence as if
by repeated calls tosputc(c)[.](#streambuf.virt.put-1.sentence-1)
The characters written are obtained from successive elements of
the array whose first element is designated by s[.](#streambuf.virt.put-1.sentence-2)
Writing stops when either n characters have been written or
a call tosputc(c) would returntraits::eof()[.](#streambuf.virt.put-1.sentence-3)
It is unspecified whether the function calls overflow() when pptr() == epptr() becomes true or whether it achieves the same effects by other means[.](#streambuf.virt.put-1.sentence-4)
[2](#streambuf.virt.put-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4017)
*Returns*: The number of characters written[.](#streambuf.virt.put-2.sentence-1)
[🔗](#lib:overflow,basic_streambuf)
`int_type overflow(int_type c = traits::eof());
`
[3](#streambuf.virt.put-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4028)
*Effects*: Consumes some initial subsequence of the characters of the[*pending sequence*](#def:pending_sequence)[.](#streambuf.virt.put-3.sentence-1)
The pending sequence is defined as the concatenation of
- [(3.1)](#streambuf.virt.put-3.1)
the empty sequence if pbase() is null, otherwise thepptr() - pbase() characters beginning atpbase(), followed by
- [(3.2)](#streambuf.virt.put-3.2)
the empty sequence
iftraits::eq_int_type(c, traits::eof()) returnstrue, otherwise the sequence consisting of c[.](#streambuf.virt.put-3.sentence-2)
[4](#streambuf.virt.put-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4047)
*Preconditions*: Every overriding definition of this virtual function
obeys the following constraints:
- [(4.1)](#streambuf.virt.put-4.1)
The effect of consuming a character on the associated output sequence is
specified[.](#streambuf.virt.put-4.1.sentence-1)[270](#footnote-270 "That is, for each class derived from a specialization of basic_­streambuf in this Clause ([stringbuf], [filebuf]), a specification of how consuming a character effects the associated output sequence is given. There is no requirement on a program-defined class.")
- [(4.2)](#streambuf.virt.put-4.2)
Letr be the number of characters in the pending sequence not consumed[.](#streambuf.virt.put-4.2.sentence-1)
Ifr is nonzero thenpbase() andpptr() are set so that:pptr() - pbase() == r and the r characters starting atpbase() are the associated output stream[.](#streambuf.virt.put-4.2.sentence-2)
In case r is zero (all characters of the pending sequence have been consumed)
then eitherpbase() is set tonullptr,
orpbase() andpptr() are both set to the same non-null value[.](#streambuf.virt.put-4.2.sentence-3)
- [(4.3)](#streambuf.virt.put-4.3)
The function may fail if either
appending some character to the associated output stream fails or
if it is unable to establishpbase() andpptr() according to the above rules[.](#streambuf.virt.put-4.3.sentence-1)
[5](#streambuf.virt.put-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4097)
*Returns*: traits::eof() or throws an exception
if the function fails[.](#streambuf.virt.put-5.sentence-1)
Otherwise,
returns some value other thantraits::eof() to indicate success[.](#streambuf.virt.put-5.sentence-2)[271](#footnote-271 "Typically, overflow returns c to indicate success, except when traits::eq_­int_­type(c, traits::eof()) returns true, in which case it returns traits::not_­eof(c).")
[6](#streambuf.virt.put-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4118)
*Default behavior*: Returnstraits::eof()[.](#streambuf.virt.put-6.sentence-1)
[7](#streambuf.virt.put-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4123)
*Remarks*: The member functionssputc() andsputn() call this function in case that
no room can be found in the put buffer enough to accommodate the
argument character sequence[.](#streambuf.virt.put-7.sentence-1)
[270)](#footnote-270)[270)](#footnoteref-270)
That is, for each class derived from a specialization ofbasic_streambuf in this Clause ([[stringbuf]](stringbuf "31.8.2Class template basic_­stringbuf"), [[filebuf]](filebuf "31.10.3Class template basic_­filebuf")),
a specification of how consuming a character effects the associated output sequence is given[.](#footnote-270.sentence-1)
There is no requirement on a program-defined class[.](#footnote-270.sentence-2)
[271)](#footnote-271)[271)](#footnoteref-271)
Typically,overflow returns c to indicate success, except whentraits::eq_int_type(c, traits::eof()) returnstrue,
in which case it returnstraits::not_eof(c)[.](#footnote-271.sentence-1)