1044 lines
37 KiB
Markdown
1044 lines
37 KiB
Markdown
[streambuf]
|
||
|
||
# 31 Input/output library [[input.output]](./#input.output)
|
||
|
||
## 31.6 Stream buffers [[stream.buffers]](stream.buffers#streambuf)
|
||
|
||
### 31.6.3 Class template basic_streambuf [streambuf]
|
||
|
||
#### [31.6.3.1](#general) General [[streambuf.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]](#locales "31.6.3.3.1 Locales"), locales locale pubimbue(const locale& loc);
|
||
locale getloc() const; // [[streambuf.buffer]](#buffer "31.6.3.3.2 Buffer 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]](#pub.get "31.6.3.3.3 Get 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]](#pub.pback "31.6.3.3.4 Putback"), putback int_type sputbackc(char_type c);
|
||
int_type sungetc(); // [[streambuf.pub.put]](#pub.put "31.6.3.3.5 Put 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]](#get.area "31.6.3.4.2 Get 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]](#put.area "31.6.3.4.3 Put 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]](#virtuals "31.6.3.5 Virtual functions"), virtual functions// [[streambuf.virt.locales]](#virt.locales "31.6.3.5.1 Locales"), localesvirtual void imbue(const locale& loc); // [[streambuf.virt.buffer]](#virt.buffer "31.6.3.5.2 Buffer 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]](#virt.get "31.6.3.5.3 Get area"), get areavirtual streamsize showmanyc(); virtual streamsize xsgetn(char_type* s, streamsize n); virtual int_type underflow(); virtual int_type uflow(); // [[streambuf.virt.pback]](#virt.pback "31.6.3.5.4 Putback"), putbackvirtual int_type pbackfail(int_type c = traits::eof()); // [[streambuf.virt.put]](#virt.put "31.6.3.5.5 Put area"), put areavirtual streamsize xsputn(const char_type* s, streamsize n); virtual int_type overflow(int_type c = traits::eof()); };}
|
||
|
||
[1](#general-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)](#general-1.1)
|
||
|
||
a character[*input sequence*](#def:input_sequence);
|
||
|
||
- [(1.2)](#general-1.2)
|
||
|
||
a character[*output sequence*](#def:output_sequence)[.](#general-1.sentence-1)
|
||
|
||
#### [31.6.3.2](#cons) Constructors [[streambuf.cons]](streambuf.cons)
|
||
|
||
[ð](#lib:basic_streambuf,constructor)
|
||
|
||
`basic_streambuf();
|
||
`
|
||
|
||
[1](#cons-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)](#cons-1.1)
|
||
|
||
all pointer member objects to null pointers,
|
||
|
||
- [(1.2)](#cons-1.2)
|
||
|
||
thegetloc() member to a copy of the global locale,locale(),
|
||
at the time of construction[.](#cons-1.sentence-1)
|
||
|
||
[2](#cons-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[.](#cons-2.sentence-1)
|
||
|
||
[ð](#lib:basic_streambuf,constructor_)
|
||
|
||
`basic_streambuf(const basic_streambuf& rhs);
|
||
`
|
||
|
||
[3](#cons-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3149)
|
||
|
||
*Postconditions*:
|
||
|
||
- [(3.1)](#cons-3.1)
|
||
|
||
eback() == rhs.eback()
|
||
|
||
- [(3.2)](#cons-3.2)
|
||
|
||
gptr() == rhs.gptr()
|
||
|
||
- [(3.3)](#cons-3.3)
|
||
|
||
egptr() == rhs.egptr()
|
||
|
||
- [(3.4)](#cons-3.4)
|
||
|
||
pbase() == rhs.pbase()
|
||
|
||
- [(3.5)](#cons-3.5)
|
||
|
||
pptr() == rhs.pptr()
|
||
|
||
- [(3.6)](#cons-3.6)
|
||
|
||
epptr() == rhs.epptr()
|
||
|
||
- [(3.7)](#cons-3.7)
|
||
|
||
getloc() == rhs.getloc()
|
||
|
||
[ð](#lib:basic_streambuf,destructor)
|
||
|
||
`~basic_streambuf();
|
||
`
|
||
|
||
[4](#cons-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3168)
|
||
|
||
*Effects*: None[.](#cons-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)
|
||
|
||
#### [31.6.3.3](#members) Public member functions [[streambuf.members]](streambuf.members)
|
||
|
||
#### [31.6.3.3.1](#locales) Locales [[streambuf.locales]](streambuf.locales)
|
||
|
||
[ð](#lib:pubimbue,basic_streambuf)
|
||
|
||
`locale pubimbue(const locale& loc);
|
||
`
|
||
|
||
[1](#locales-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3183)
|
||
|
||
*Effects*: Callsimbue(loc)[.](#locales-1.sentence-1)
|
||
|
||
[2](#locales-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3188)
|
||
|
||
*Postconditions*: loc == getloc()[.](#locales-2.sentence-1)
|
||
|
||
[3](#locales-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3192)
|
||
|
||
*Returns*: Previous value ofgetloc()[.](#locales-3.sentence-1)
|
||
|
||
[ð](#lib:getloc,basic_streambuf)
|
||
|
||
`locale getloc() const;
|
||
`
|
||
|
||
[4](#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[.](#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[.](#locales-4.sentence-2)
|
||
|
||
#### [31.6.3.3.2](#buffer) Buffer management and positioning [[streambuf.buffer]](streambuf.buffer)
|
||
|
||
[ð](#lib:pubsetbuf,basic_streambuf)
|
||
|
||
`basic_streambuf* pubsetbuf(char_type* s, streamsize n);
|
||
`
|
||
|
||
[1](#buffer-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3229)
|
||
|
||
*Returns*: setbuf(s, n)[.](#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](#buffer-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3242)
|
||
|
||
*Returns*: seekoff(off, way, which)[.](#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](#buffer-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3255)
|
||
|
||
*Returns*: seekpos(sp, which)[.](#buffer-3.sentence-1)
|
||
|
||
[ð](#lib:pubsync,basic_streambuf)
|
||
|
||
`int pubsync();
|
||
`
|
||
|
||
[4](#buffer-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3266)
|
||
|
||
*Returns*: sync()[.](#buffer-4.sentence-1)
|
||
|
||
#### [31.6.3.3.3](#pub.get) Get area [[streambuf.pub.get]](streambuf.pub.get)
|
||
|
||
[ð](#lib:in_avail,basic_streambuf)
|
||
|
||
`streamsize in_avail();
|
||
`
|
||
|
||
[1](#pub.get-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3279)
|
||
|
||
*Returns*: If a read position is available, returnsegptr() - gptr()[.](#pub.get-1.sentence-1)
|
||
|
||
Otherwise returns[showmanyc()](filebuf.virtuals#lib:basic_streambuf,showmanyc "31.10.3.5 Overridden virtual functions [filebuf.virtuals]")[.](#pub.get-1.sentence-2)
|
||
|
||
[ð](#lib:snextc,basic_streambuf)
|
||
|
||
`int_type snextc();
|
||
`
|
||
|
||
[2](#pub.get-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3293)
|
||
|
||
*Effects*: Callssbumpc()[.](#pub.get-2.sentence-1)
|
||
|
||
[3](#pub.get-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3298)
|
||
|
||
*Returns*: If that function returnstraits::eof(),
|
||
returnstraits::eof()[.](#pub.get-3.sentence-1)
|
||
|
||
Otherwise, returnssgetc()[.](#pub.get-3.sentence-2)
|
||
|
||
[ð](#lib:sbumpc,basic_streambuf)
|
||
|
||
`int_type sbumpc();
|
||
`
|
||
|
||
[4](#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()[.](#pub.get-4.sentence-1)
|
||
|
||
Otherwise, returnstraits::to_int_type(*gptr()) and increments the next pointer for the input sequence[.](#pub.get-4.sentence-2)
|
||
|
||
[ð](#lib:sgetc,basic_streambuf)
|
||
|
||
`int_type sgetc();
|
||
`
|
||
|
||
[5](#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()[.](#pub.get-5.sentence-1)
|
||
|
||
Otherwise, returnstraits::to_int_type(*gptr())[.](#pub.get-5.sentence-2)
|
||
|
||
[ð](#lib:sgetn,basic_streambuf)
|
||
|
||
`streamsize sgetn(char_type* s, streamsize n);
|
||
`
|
||
|
||
[6](#pub.get-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3345)
|
||
|
||
*Returns*: xsgetn(s, n)[.](#pub.get-6.sentence-1)
|
||
|
||
#### [31.6.3.3.4](#pub.pback) Putback [[streambuf.pub.pback]](streambuf.pub.pback)
|
||
|
||
[ð](#lib:sputbackc,basic_streambuf)
|
||
|
||
`int_type sputbackc(char_type c);
|
||
`
|
||
|
||
[1](#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))[.](#pub.pback-1.sentence-1)
|
||
|
||
Otherwise, decrements the next pointer for the input sequence and
|
||
returnstraits::to_int_type(*gptr())[.](#pub.pback-1.sentence-2)
|
||
|
||
[ð](#lib:sungetc,basic_streambuf)
|
||
|
||
`int_type sungetc();
|
||
`
|
||
|
||
[2](#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()[.](#pub.pback-2.sentence-1)
|
||
|
||
Otherwise, decrements the next pointer for the input sequence and
|
||
returnstraits::to_int_type(*gptr())[.](#pub.pback-2.sentence-2)
|
||
|
||
#### [31.6.3.3.5](#pub.put) Put area [[streambuf.pub.put]](streambuf.pub.put)
|
||
|
||
[ð](#lib:sputc,basic_streambuf)
|
||
|
||
`int_type sputc(char_type c);
|
||
`
|
||
|
||
[1](#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))[.](#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)[.](#pub.put-1.sentence-2)
|
||
|
||
[ð](#lib:sputn,basic_streambuf)
|
||
|
||
`streamsize sputn(const char_type* s, streamsize n);
|
||
`
|
||
|
||
[2](#pub.put-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3411)
|
||
|
||
*Returns*: xsputn(s, n)[.](#pub.put-2.sentence-1)
|
||
|
||
#### [31.6.3.4](#protected) Protected member functions [[streambuf.protected]](streambuf.protected)
|
||
|
||
#### [31.6.3.4.1](#assign) Assignment [[streambuf.assign]](streambuf.assign)
|
||
|
||
[ð](#lib:operator=,basic_streambuf)
|
||
|
||
`basic_streambuf& operator=(const basic_streambuf& rhs);
|
||
`
|
||
|
||
[1](#assign-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3426)
|
||
|
||
*Postconditions*:
|
||
|
||
- [(1.1)](#assign-1.1)
|
||
|
||
eback() == rhs.eback()
|
||
|
||
- [(1.2)](#assign-1.2)
|
||
|
||
gptr() == rhs.gptr()
|
||
|
||
- [(1.3)](#assign-1.3)
|
||
|
||
egptr() == rhs.egptr()
|
||
|
||
- [(1.4)](#assign-1.4)
|
||
|
||
pbase() == rhs.pbase()
|
||
|
||
- [(1.5)](#assign-1.5)
|
||
|
||
pptr() == rhs.pptr()
|
||
|
||
- [(1.6)](#assign-1.6)
|
||
|
||
epptr() == rhs.epptr()
|
||
|
||
- [(1.7)](#assign-1.7)
|
||
|
||
getloc() == rhs.getloc()
|
||
|
||
[2](#assign-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3438)
|
||
|
||
*Returns*: *this[.](#assign-2.sentence-1)
|
||
|
||
[ð](#lib:swap,basic_streambuf)
|
||
|
||
`void swap(basic_streambuf& rhs);
|
||
`
|
||
|
||
[3](#assign-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3449)
|
||
|
||
*Effects*: Swaps the data members of rhs and *this[.](#assign-3.sentence-1)
|
||
|
||
#### [31.6.3.4.2](#get.area) Get area access [[streambuf.get.area]](streambuf.get.area)
|
||
|
||
[ð](#lib:eback,basic_streambuf)
|
||
|
||
`char_type* eback() const;
|
||
`
|
||
|
||
[1](#get.area-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3463)
|
||
|
||
*Returns*: The beginning pointer for the input sequence[.](#get.area-1.sentence-1)
|
||
|
||
[ð](#lib:gptr,basic_streambuf)
|
||
|
||
`char_type* gptr() const;
|
||
`
|
||
|
||
[2](#get.area-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3474)
|
||
|
||
*Returns*: The next pointer for the input sequence[.](#get.area-2.sentence-1)
|
||
|
||
[ð](#lib:egptr,basic_streambuf)
|
||
|
||
`char_type* egptr() const;
|
||
`
|
||
|
||
[3](#get.area-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3485)
|
||
|
||
*Returns*: The end pointer for the input sequence[.](#get.area-3.sentence-1)
|
||
|
||
[ð](#lib:gbump,basic_streambuf)
|
||
|
||
`void gbump(int n);
|
||
`
|
||
|
||
[4](#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[.](#get.area-4.sentence-1)
|
||
|
||
[ð](#lib:setg,basic_streambuf)
|
||
|
||
`void setg(char_type* gbeg, char_type* gnext, char_type* gend);
|
||
`
|
||
|
||
[5](#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[.](#get.area-5.sentence-1)
|
||
|
||
[6](#get.area-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3512)
|
||
|
||
*Postconditions*: gbeg == eback(),gnext == gptr(),
|
||
andgend == egptr() are all true[.](#get.area-6.sentence-1)
|
||
|
||
#### [31.6.3.4.3](#put.area) Put area access [[streambuf.put.area]](streambuf.put.area)
|
||
|
||
[ð](#lib:pbase,basic_streambuf)
|
||
|
||
`char_type* pbase() const;
|
||
`
|
||
|
||
[1](#put.area-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3528)
|
||
|
||
*Returns*: The beginning pointer for the output sequence[.](#put.area-1.sentence-1)
|
||
|
||
[ð](#lib:pptr,basic_streambuf)
|
||
|
||
`char_type* pptr() const;
|
||
`
|
||
|
||
[2](#put.area-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3539)
|
||
|
||
*Returns*: The next pointer for the output sequence[.](#put.area-2.sentence-1)
|
||
|
||
[ð](#lib:epptr,basic_streambuf)
|
||
|
||
`char_type* epptr() const;
|
||
`
|
||
|
||
[3](#put.area-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3550)
|
||
|
||
*Returns*: The end pointer for the output sequence[.](#put.area-3.sentence-1)
|
||
|
||
[ð](#lib:pbump,basic_streambuf)
|
||
|
||
`void pbump(int n);
|
||
`
|
||
|
||
[4](#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[.](#put.area-4.sentence-1)
|
||
|
||
[ð](#lib:setp,basic_streambuf)
|
||
|
||
`void setp(char_type* pbeg, char_type* pend);
|
||
`
|
||
|
||
[5](#put.area-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3572)
|
||
|
||
*Preconditions*: [pbeg, pend) is a valid range[.](#put.area-5.sentence-1)
|
||
|
||
[6](#put.area-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3576)
|
||
|
||
*Postconditions*: pbeg == pbase(),pbeg == pptr(),
|
||
andpend == epptr() are all true[.](#put.area-6.sentence-1)
|
||
|
||
#### [31.6.3.5](#virtuals) Virtual functions [[streambuf.virtuals]](streambuf.virtuals)
|
||
|
||
#### [31.6.3.5.1](#virt.locales) Locales [[streambuf.virt.locales]](streambuf.virt.locales)
|
||
|
||
[ð](#lib:imbue,basic_streambuf)
|
||
|
||
`void imbue(const locale&);
|
||
`
|
||
|
||
[1](#virt.locales-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3594)
|
||
|
||
*Effects*: Change any translations based on locale[.](#virt.locales-1.sentence-1)
|
||
|
||
[2](#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[.](#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[.](#virt.locales-2.sentence-2)
|
||
|
||
[3](#virt.locales-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3606)
|
||
|
||
*Default behavior*: Does nothing[.](#virt.locales-3.sentence-1)
|
||
|
||
#### [31.6.3.5.2](#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](#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.5 Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5 Overridden virtual functions"))[.](#virt.buffer-1.sentence-1)
|
||
|
||
[2](#virt.buffer-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3626)
|
||
|
||
*Default behavior*: Does nothing[.](#virt.buffer-2.sentence-1)
|
||
|
||
Returnsthis[.](#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](#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.5 Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5 Overridden virtual functions"))[.](#virt.buffer-3.sentence-1)
|
||
|
||
[4](#virt.buffer-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3649)
|
||
|
||
*Default behavior*: Returnspos_type(off_type(-1))[.](#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](#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.2 Class template basic_stringbuf"), [[filebuf]](filebuf "31.10.3 Class template basic_filebuf"))[.](#virt.buffer-5.sentence-1)
|
||
|
||
[6](#virt.buffer-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3671)
|
||
|
||
*Default behavior*: Returnspos_type(off_type(-1))[.](#virt.buffer-6.sentence-1)
|
||
|
||
[ð](#lib:sync,basic_streambuf)
|
||
|
||
`int sync();
|
||
`
|
||
|
||
[7](#virt.buffer-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3683)
|
||
|
||
*Effects*: Synchronizes the controlled sequences with the arrays[.](#virt.buffer-7.sentence-1)
|
||
|
||
That is, ifpbase() is non-null the characters betweenpbase() andpptr() are written to the controlled sequence[.](#virt.buffer-7.sentence-2)
|
||
|
||
The pointers may then be reset as appropriate[.](#virt.buffer-7.sentence-3)
|
||
|
||
[8](#virt.buffer-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3695)
|
||
|
||
*Returns*: -1 on failure[.](#virt.buffer-8.sentence-1)
|
||
|
||
What constitutes failure is determined by each derived class ([[filebuf.virtuals]](filebuf.virtuals "31.10.3.5 Overridden virtual functions"))[.](#virt.buffer-8.sentence-2)
|
||
|
||
[9](#virt.buffer-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3700)
|
||
|
||
*Default behavior*: Returns zero[.](#virt.buffer-9.sentence-1)
|
||
|
||
#### [31.6.3.5.3](#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](#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[.](#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[.](#virt.get-1.sentence-2)
|
||
|
||
Ifshowmanyc() returns â1, then calls tounderflow() oruflow() will fail[.](#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](#virt.get-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3744)
|
||
|
||
*Default behavior*: Returns zero[.](#virt.get-2.sentence-1)
|
||
|
||
[3](#virt.get-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3748)
|
||
|
||
*Remarks*: Usestraits::eof()[.](#virt.get-3.sentence-1)
|
||
|
||
[ð](#lib:xsgetn,basic_streambuf)
|
||
|
||
`streamsize xsgetn(char_type* s, streamsize n);
|
||
`
|
||
|
||
[4](#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[.](#virt.get-4.sentence-1)
|
||
|
||
The characters assigned are read from the input sequence as if
|
||
by repeated calls tosbumpc()[.](#virt.get-4.sentence-2)
|
||
|
||
Assigning stops when either n characters
|
||
have been assigned or a call tosbumpc() would returntraits::eof()[.](#virt.get-4.sentence-3)
|
||
|
||
[5](#virt.get-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3773)
|
||
|
||
*Returns*: The number of characters assigned[.](#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](#virt.get-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3786)
|
||
|
||
*Remarks*: Usestraits::eof()[.](#virt.get-6.sentence-1)
|
||
|
||
[ð](#lib:underflow,basic_streambuf)
|
||
|
||
`int_type underflow();
|
||
`
|
||
|
||
[7](#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)](#virt.get-7.1)
|
||
|
||
the empty sequence if gptr() is null, otherwise the
|
||
characters in
|
||
[gptr(), egptr()),
|
||
followed by
|
||
|
||
- [(7.2)](#virt.get-7.2)
|
||
|
||
some (possibly empty) sequence of characters read from the input sequence[.](#virt.get-7.sentence-1)
|
||
|
||
[8](#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[.](#virt.get-8.sentence-1)
|
||
|
||
[9](#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())[.](#virt.get-9.sentence-1)
|
||
|
||
[10](#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()[.](#virt.get-10.sentence-1)
|
||
|
||
[11](#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)](#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)](#virt.get-11.2)
|
||
|
||
the characters in [gptr() - n, gptr())
|
||
agree with the backup sequence (where n is the length of the backup sequence)[.](#virt.get-11.sentence-1)
|
||
|
||
[12](#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[.](#virt.get-12.sentence-1)
|
||
|
||
If the pending sequence is null then the function returnstraits::eof() to indicate failure[.](#virt.get-12.sentence-2)
|
||
|
||
[13](#virt.get-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3875)
|
||
|
||
*Default behavior*: Returnstraits::eof()[.](#virt.get-13.sentence-1)
|
||
|
||
[14](#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()[.](#virt.get-14.sentence-1)
|
||
|
||
[ð](#lib:uflow,basic_streambuf)
|
||
|
||
`int_type uflow();
|
||
`
|
||
|
||
[15](#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[.](#virt.get-15.sentence-1)
|
||
|
||
[16](#virt.get-16)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3903)
|
||
|
||
*Default behavior*: Callsunderflow()[.](#virt.get-16.sentence-1)
|
||
|
||
Ifunderflow() returnstraits::eof(),
|
||
returnstraits::eof()[.](#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[.](#virt.get-16.sentence-3)
|
||
|
||
[17](#virt.get-17)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3917)
|
||
|
||
*Returns*: traits::eof() to indicate failure[.](#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](#virt.pback) Putback [[streambuf.virt.pback]](streambuf.virt.pback)
|
||
|
||
[ð](#lib:pbackfail,basic_streambuf)
|
||
|
||
`int_type pbackfail(int_type c = traits::eof());
|
||
`
|
||
|
||
[1](#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)](#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[.](#virt.pback-1.1.sentence-1)
|
||
|
||
- [(1.2)](#virt.pback-1.2)
|
||
|
||
Iftraits::eq_int_type(c, traits::eof()) returns false, then c is prepended[.](#virt.pback-1.2.sentence-1)
|
||
Whether the input sequence is backed up or modified in any other way is unspecified[.](#virt.pback-1.2.sentence-2)
|
||
|
||
[2](#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()[.](#virt.pback-2.sentence-1)
|
||
|
||
[3](#virt.pback-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3961)
|
||
|
||
*Returns*: traits::eof() to indicate failure[.](#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[.](#virt.pback-3.sentence-2)
|
||
|
||
pbackfail() is called only when put back has really failed[.](#virt.pback-3.sentence-3)
|
||
|
||
[4](#virt.pback-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3970)
|
||
|
||
Returns some value other thantraits::eof() to indicate success[.](#virt.pback-4.sentence-1)
|
||
|
||
[5](#virt.pback-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L3975)
|
||
|
||
*Default behavior*: Returnstraits::eof()[.](#virt.pback-5.sentence-1)
|
||
|
||
[6](#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[.](#virt.pback-6.sentence-1)
|
||
|
||
Other calls shall also satisfy that constraint[.](#virt.pback-6.sentence-2)
|
||
|
||
#### [31.6.3.5.5](#virt.put) Put area [[streambuf.virt.put]](streambuf.virt.put)
|
||
|
||
[ð](#lib:xsputn,basic_streambuf)
|
||
|
||
`streamsize xsputn(const char_type* s, streamsize n);
|
||
`
|
||
|
||
[1](#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)[.](#virt.put-1.sentence-1)
|
||
|
||
The characters written are obtained from successive elements of
|
||
the array whose first element is designated by s[.](#virt.put-1.sentence-2)
|
||
|
||
Writing stops when either n characters have been written or
|
||
a call tosputc(c) would returntraits::eof()[.](#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[.](#virt.put-1.sentence-4)
|
||
|
||
[2](#virt.put-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4017)
|
||
|
||
*Returns*: The number of characters written[.](#virt.put-2.sentence-1)
|
||
|
||
[ð](#lib:overflow,basic_streambuf)
|
||
|
||
`int_type overflow(int_type c = traits::eof());
|
||
`
|
||
|
||
[3](#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)[.](#virt.put-3.sentence-1)
|
||
|
||
The pending sequence is defined as the concatenation of
|
||
|
||
- [(3.1)](#virt.put-3.1)
|
||
|
||
the empty sequence if pbase() is null, otherwise thepptr() - pbase() characters beginning atpbase(), followed by
|
||
|
||
- [(3.2)](#virt.put-3.2)
|
||
|
||
the empty sequence
|
||
iftraits::eq_int_type(c, traits::eof()) returnstrue, otherwise the sequence consisting of c[.](#virt.put-3.sentence-2)
|
||
|
||
[4](#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)](#virt.put-4.1)
|
||
|
||
The effect of consuming a character on the associated output sequence is
|
||
specified[.](#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)](#virt.put-4.2)
|
||
|
||
Letr be the number of characters in the pending sequence not consumed[.](#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[.](#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[.](#virt.put-4.2.sentence-3)
|
||
|
||
- [(4.3)](#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[.](#virt.put-4.3.sentence-1)
|
||
|
||
[5](#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[.](#virt.put-5.sentence-1)
|
||
|
||
Otherwise,
|
||
returns some value other thantraits::eof() to indicate success[.](#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](#virt.put-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4118)
|
||
|
||
*Default behavior*: Returnstraits::eof()[.](#virt.put-6.sentence-1)
|
||
|
||
[7](#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[.](#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.2 Class template basic_stringbuf"), [[filebuf]](filebuf "31.10.3 Class 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)
|