std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf (3) - Linux Manuals
std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf: std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf
NAME
std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf - std::basic_stringbuf<CharT,Traits,Allocator>::basic_stringbuf
Synopsis
basic_stringbuf() : basic_stringbuf(std::ios_base::in | std::ios_base::out) { } (1)
explicit basic_stringbuf( std::ios_base::openmode which = std::ios_base::in (until C++11)
| std::ios_base::out );
explicit basic_stringbuf( std::ios_base::openmode which ); (since C++11)
explicit basic_stringbuf( const std::basic_string<CharT, traits, Allocator>& new_str, (2)
std::ios_base::openmode which = std::ios_base::in (3)
| std::ios_base::out );
basic_stringbuf( const basic_stringbuf& rhs ) = delete; (4) (since C++11)
basic_stringbuf( basic_stringbuf&& rhs ); (5) (since C++11)
1) Default constructor. It is implementation-defined whether the sequence pointers (eback(), gptr(), egptr(), pbase(), pptr(), epptr()) are initialized to null pointers.
2) Constructs a std::basic_stringbuf object: initializes the base class by calling the default constructor of std::basic_streambuf, initializes the character sequence with an empty string, and sets the mode to which.
3) Constructs a std::basic_stringbuf object by performing the same initialization as 1), followed by initializing the associated character sequence as if by calling str(new_str).
4) The copy constructor is deleted; std::basic_stringbuf is not CopyConstructible
5) Move-constructs a std::basic_stringbuf object by moving all state from another std::basic_stringbuf object rhs, including the associated string, the open mode, the locale, and all other state. After the move, the six pointers of std::basic_streambuf in *this are guaranteed to be different from the corresponding pointers in the moved-from rhs unless null.
Parameters
new_str - a basic_string used to initialize the buffer
rhs - another basic_stringbuf
which - binary open in binary_mode
Notes
Typically called by the constructor of std::basic_stringstream.
The level of support for the open modes other than std::ios_base::in and std::ios_base::out varies among implementations. C++11 explicitly specifies the support for std::ios_base::ate in str() and in this constructor, but std::ios_base::app, std::ios_base::trunc, and std::ios_base::binary have different effects on different implementations.
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
P0935R0 C++11 default constructor was explicit made implicit
Example
Demonstrates calling the constructor of basic_stringbuf directly.
// Run this code