29 Input/output library [input.output]

29.8 String-based streams [string.streams]

29.8.2 Class template basic_­stringbuf [stringbuf]

29.8.2.2 Constructors [stringbuf.cons]

explicit basic_stringbuf(ios_base::openmode which);
Effects: Initializes the base class with basic_­streambuf() ([streambuf.cons]), and mode with which.
It is implementation-defined whether the sequence pointers (eback(), gptr(), egptr(), pbase(), pptr(), epptr()) are initialized to null pointers.
Postconditions: str().empty() is true.
explicit basic_stringbuf( const basic_string<charT, traits, Allocator>& s, ios_base::openmode which = ios_base::in | ios_base::out);
Effects: Initializes the base class with basic_­streambuf() ([streambuf.cons]), mode with which, and buf with s, then calls init_­buf_­ptrs().
basic_stringbuf(ios_base::openmode which, const Allocator &a);
Effects: Initializes the base class with basic_­streambuf() ([streambuf.cons]), mode with which, and buf with a, then calls init_­buf_­ptrs().
Postconditions: str().empty() is true.
explicit basic_stringbuf( basic_string<charT, traits, Allocator>&& s, ios_base::openmode which = ios_base::in | ios_base::out);
Effects: Initializes the base class with basic_­streambuf() ([streambuf.cons]), mode with which, and buf with std​::​move(s), then calls init_­buf_­ptrs().
template<class SAlloc> basic_stringbuf( const basic_string<charT, traits, SAlloc>& s, ios_base::openmode which, const Allocator &a);
Effects: Initializes the base class with basic_­streambuf() ([streambuf.cons]), mode with which, and buf with {s,a}, then calls init_­buf_­ptrs().
template<class SAlloc> explicit basic_stringbuf( const basic_string<charT, traits, SAlloc>& s, ios_base::openmode which = ios_base::in | ios_base::out);
Constraints: is_­same_­v<SAlloc,Allocator> is false.
Effects: Initializes the base class with basic_­streambuf() ([streambuf.cons]), mode with which, and buf with s, then calls init_­buf_­ptrs().
basic_stringbuf(basic_stringbuf&& rhs); basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
Effects: Copy constructs the base class from rhs and initializes mode with rhs.mode.
In the first form buf is initialized from std​::​move(rhs).str().
In the second form buf is initialized from {std​::​move(rhs).str(), a}.
It is implementation-defined whether the sequence pointers in *this (eback(), gptr(), egptr(), pbase(), pptr(), epptr()) obtain the values which rhs had.
Postconditions: Let rhs_­p refer to the state of rhs just prior to this construction and let rhs_­a refer to the state of rhs just after this construction.
  • str() == rhs_­p.str()
  • gptr() - eback() == rhs_­p.gptr() - rhs_­p.eback()
  • egptr() - eback() == rhs_­p.egptr() - rhs_­p.eback()
  • pptr() - pbase() == rhs_­p.pptr() - rhs_­p.pbase()
  • epptr() - pbase() == rhs_­p.epptr() - rhs_­p.pbase()
  • if (eback()) eback() != rhs_­a.eback()
  • if (gptr()) gptr() != rhs_­a.gptr()
  • if (egptr()) egptr() != rhs_­a.egptr()
  • if (pbase()) pbase() != rhs_­a.pbase()
  • if (pptr()) pptr() != rhs_­a.pptr()
  • if (epptr()) epptr() != rhs_­a.epptr()
  • getloc() == rhs_­p.getloc()
  • rhs is empty but usable, as if std​::​move(rhs).str() was called.