Standard C++ Library Reference ISO/IEC (VERSION3)
Otherwise (or if neither position is affected) the positioning operation fails.
If the function succeeds in altering either or both of the stream positions, it returns the resultant
stream position. Otherwise, it fails and returns an invalid stream position.
basic_stringbuf::str
basic_string<Elem, Tr, Alloc> str() const;
void str(const basic_string<Elem, Tr, Alloc>& newstr);
The first member function returns an object of class basic_string<Elem, Tr,
Alloc>, whose controlled sequence is a copy of the sequence controlled by *this. The
sequence copied depends on the stored stringbuf mode mode:
If mode & ios_base::out is nonzero and an output buffer exists, the sequence is
the entire output buffer (epptr() - pbase() elements beginning with pbase()).
●
Otherwise, if mode & ios_base::in is nonzero and an input buffer exists, the
sequence is the entire input buffer (egptr() - eback() elements beginning with
eback()).
●
Otherwise, the copied sequence is empty.●
The second member function deallocates any sequence currently controlled by *this. It then
allocates a copy of the sequence controlled by newstr. If mode & ios_base::in is
nonzero, it sets the input buffer to begin reading at the beginning of the sequence. If mode &
ios_base::out is nonzero, it sets the output buffer to begin writing at the beginning of the
sequence.
basic_stringbuf::traits_type
typedef Tr traits_type;
The type is a synonym for the template parameter Tr.
basic_stringbuf::underflow
virtual int_type underflow();
The protected virtual member function endeavors to extract the current element byte from the
input buffer, then advance the current stream position, and return the element as
traits_type::to_int_type(byte). It can do so in only one way: If a read position is
available, it takes byte as the element stored in the read position and advances the next pointer
for the input buffer.
If the function cannot succeed, it returns traits_type::eof(). Otherwise, it returns the
current element in the input stream, converted as described above.