Files
2025-10-25 03:02:53 +03:00

6.8 KiB
Raw Permalink Blame History

[stringbuf.cons]

31 Input/output library [input.output]

31.8 String-based streams [string.streams]

31.8.2 Class template basic_stringbuf [stringbuf]

31.8.2.2 Constructors [stringbuf.cons]

🔗

explicit basic_stringbuf(ios_base::openmode which);

1

#

Effects: Initializes the base class withbasic_streambuf() ([streambuf.cons]), andmode with which.

It isimplementation-defined whether the sequence pointers (eback(), gptr(), egptr(),pbase(), pptr(), epptr()) are initialized to null pointers.

2

#

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);

3

#

Effects: Initializes the base class withbasic_streambuf() ([streambuf.cons]),mode with which, andbuf with s, then calls init-buf-ptrs().

🔗

basic_stringbuf(ios_base::openmode which, const Allocator& a);

4

#

Effects: Initializes the base class withbasic_streambuf() ([streambuf.cons]),mode with which, andbuf with a, then calls init-buf-ptrs().

5

#

Postconditions: str().empty() is true.

🔗

explicit basic_stringbuf( basic_string<charT, traits, Allocator>&& s, ios_base::openmode which = ios_base::in | ios_base::out);

6

#

Effects: Initializes the base class with basic_streambuf() ([streambuf.cons]),mode with which, andbuf 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);

7

#

Effects: Initializes the base class with basic_streambuf() ([streambuf.cons]),mode with which, andbuf 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);

8

#

Constraints: is_same_v<SAlloc, Allocator> is false.

9

#

Effects: Initializes the base class with basic_streambuf() ([streambuf.cons]),mode with which, andbuf with s, then calls init-buf-ptrs().

🔗

template<class T> explicit basic_stringbuf(const T& t, ios_base::openmode which = ios_base::in | ios_base::out); template<class T> basic_stringbuf(const T& t, const Allocator& a); template<class T> basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a);

10

#

Let which be ios_base::in | ios_base::out for the overload with no parameter which, anda be Allocator() for the overload with no parameter a.

11

#

Constraints: is_convertible_v<const T&, basic_string_view<charT, traits>> is true.

12

#

Effects: Creates a variable sv as if bybasic_string_view<charT, traits> sv = t, then value-initializes the base class, initializes mode with which, and direct-non-list-initializes buf with sv, a, then calls init-buf-ptrs().

🔗

basic_stringbuf(basic_stringbuf&& rhs); basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);

13

#

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 isimplementation-defined whether the sequence pointers in *this (eback(), gptr(), egptr(),pbase(), pptr(), epptr()) obtain the values which rhs had.

14

#

Postconditions: Let rhs_p refer to the state ofrhs 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.