public member function
<sstream>
std::basic_stringbuf::basic_stringbuf
| default (1) | explicit basic_stringbuf (ios_base::openmode which = ios_base::in | ios_base::out); |
|---|---|
| initialization (2) | explicit basic_stringbuf (const basic_string<char_type,traits_type,allocator_type>& str, ios_base::openmode which = ios_base::in | ios_base::out); |
| default (1) | explicit basic_stringbuf (ios_base::openmode which = ios_base::in | ios_base::out); |
|---|---|
| initialization (2) | explicit basic_stringbuf (const basic_string<char_type,traits_type,allocator_type>& str, ios_base::openmode which = ios_base::in | ios_base::out); |
| copy (3) | basic_stringbuf (const basic_stringbuf&) = delete; |
| move (4) | basic_stringbuf (basic_stringbuf&& x); |
Construct object
- (1) empty constructor (default constructor)
- Constructs a basic_stringbuf object with an empty sequence as content, and argument which as open mode.
- (2) initialization constructor
- Constructs a basic_stringbuf object with a copy of str as content, and argument which as open mode.
- (3) copy constructor (deleted)
- Deleted (no copy constructor).
- (4) move constructor
- Acquires the contents of x.
x is left in an unspecified but valid state.
It is unspecified whether the internal sequence is the one in x before the call, or a copy of it. In any case, both objects use independent sequences after the call.
Parameters
- str
- A basic_string object with the same template parameters (charT, traits and Alloc), whose content is copied.
- x
- A basic_stringbuf object of the same type (with the same class template parameters charT, traits and Alloc), whose value is moved.
- which
- Open mode: Access given to the internal sequence of characters through the internal pointers that define the stream buffer's input sequence and output sequence. It is an object of type ios_base::openmode for which any combination of the following constant values is significant:
value stands for access ios_base::in input The sequence can be read: Members eback, gptr and egptr are maintained with values pointing to elements of the internal character sequence. ios_base::out output The sequence can be written: Members pbase, pptr and epptr are maintained with values pointing to elements of the internal character sequence. Other values of type ios_base::openmode may also be specified, although whether they have an effect on basic_stringbuf objects depends on the library implementation.
value stands for access ios_base::in input The sequence can be read: Members eback, gptr and egptr are maintained with values pointing to elements of the internal character sequence. ios_base::out output The sequence can be written: Members pbase, pptr and epptr are maintained with values pointing to elements of the internal character sequence. ios_base::ate at end The put pointer (pptr) starts at the end of the sequence, and is reset to that position every time the contents are changed using member str. Other values of type ios_base::openmode (such as ios_base::app) may also be specified, although whether they have an effect on basic_stringbuf objects depends on the library implementation.
Example
|
|
Output:
Data races
The move constructor (4) modifies x.Exception safety
Strong guarantee: if an exception is thrown, there are no side effects.See also
- basic_stringbuf::str
- Get/set content (public member function)