30 Input/output library [input.output]

30.8 String-based streams [string.streams]

30.8.2 Class template basic_­stringbuf [stringbuf]

30.8.2.3 Member functions [stringbuf.members]

basic_string<charT, traits, Allocator> str() const;

Returns: A basic_­string object whose content is equal to the basic_­stringbuf underlying character sequence. If the basic_­stringbuf was created only in input mode, the resultant basic_­string contains the character sequence in the range [eback(), egptr()). If the basic_­stringbuf was created with which & ios_­base​::​out being nonzero then the resultant basic_­string contains the character sequence in the range [pbase(), high_­mark), where high_­mark represents the position one past the highest initialized character in the buffer. Characters can be initialized by writing to the stream, by constructing the basic_­stringbuf with a basic_­string, or by calling the str(basic_­string) member function. In the case of calling the str(basic_­string) member function, all characters initialized prior to the call are now considered uninitialized (except for those characters re-initialized by the new basic_­string). Otherwise the basic_­stringbuf has been created in neither input nor output mode and a zero length basic_­string is returned.

void str(const basic_string<charT, traits, Allocator>& s);

Effects: Copies the content of s into the basic_­stringbuf underlying character sequence and initializes the input and output sequences according to mode.

Postconditions: If mode & ios_­base​::​out is nonzero, pbase() points to the first underlying character and epptr() >= pbase() + s.size() holds; in addition, if mode & ios_­base​::​ate is nonzero, pptr() == pbase() + s.size() holds, otherwise pptr() == pbase() is true. If mode & ios_­base​::​in is nonzero, eback() points to the first underlying character, and both gptr() == eback() and egptr() == eback() + s.size() hold.