Init
This commit is contained in:
502
cppdraft/streambuf/virtuals.md
Normal file
502
cppdraft/streambuf/virtuals.md
Normal 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.5 Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5 Overridden 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.5 Overridden virtual functions"), [[filebuf.virtuals]](filebuf.virtuals "31.10.3.5 Overridden 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.2 Class template basic_stringbuf"), [[filebuf]](filebuf "31.10.3 Class 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.5 Overridden 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.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)
|
||||
Reference in New Issue
Block a user