Skip to content

Commit

Permalink
Merge 2023-06 LWG Motion 9
Browse files Browse the repository at this point in the history
P2495R3 Interfacing stringstreams with string_view
  • Loading branch information
tkoeppe authored Jul 21, 2023
2 parents 0cf7b17 + 57f069a commit 07f574a
Show file tree
Hide file tree
Showing 2 changed files with 225 additions and 0 deletions.
224 changes: 224 additions & 0 deletions source/iostreams.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7952,6 +7952,13 @@
explicit basic_stringbuf(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which = ios_base::in | ios_base::out);
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);
basic_stringbuf(const basic_stringbuf&) = delete;
basic_stringbuf(basic_stringbuf&& rhs);
basic_stringbuf(basic_stringbuf&& rhs, const Allocator& a);
Expand All @@ -7974,6 +7981,8 @@
template<class SAlloc>
void str(const basic_string<charT, traits, SAlloc>& s);
void str(basic_string<charT, traits, Allocator>&& s);
template<class T>
void str(const T& t);

protected:
// \ref{stringbuf.virtuals}, overridden virtual functions
Expand Down Expand Up @@ -8142,6 +8151,37 @@
then calls \tcode{init_buf_ptrs()}.
\end{itemdescr}

\indexlibraryctor{basic_stringbuf}%
\begin{itemdecl}
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);
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{which} be \tcode{ios_base::in | ios_base::out}
for the overload with no parameter \tcode{which}, and
\tcode{a} be \tcode{Allocator()} for the overload with no parameter \tcode{a}.

\pnum
\constraints
\tcode{is_convertible_v<const T\&, basic_string_view<charT, traits>>}
is \tcode{true}.

\pnum
\effects
Creates a variable \tcode{sv} as if by
\tcode{basic_string_view<charT, traits> sv = t},
then value-initializes the base class,
initializes \tcode{mode} with \tcode{which}, and
direct-non-list-initializes \tcode{buf} with \tcode{sv, a},
then calls \tcode{init_buf_ptrs()}.
\end{itemdescr}

\indexlibraryctor{basic_stringbuf}%
\begin{itemdecl}
basic_stringbuf(basic_stringbuf&& rhs);
Expand Down Expand Up @@ -8444,6 +8484,28 @@
\end{codeblock}
\end{itemdescr}

\indexlibrarymember{str}{basic_stringbuf}%
\begin{itemdecl}
template<class T>
void str(const T& t);
\end{itemdecl}

\begin{itemdescr}
\pnum
\constraints
\tcode{is_convertible_v<const T\&, basic_string_view<charT, traits>>}
is \tcode{true}.

\pnum
\effects
Equivalent to:
\begin{codeblock}
basic_string_view<charT, traits> sv = t;
buf = sv;
init_buf_ptrs();
\end{codeblock}
\end{itemdescr}

\rSec3[stringbuf.virtuals]{Overridden virtual functions}

\indexlibrarymember{underflow}{basic_stringbuf}%
Expand Down Expand Up @@ -8749,6 +8811,12 @@
explicit basic_istringstream(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which = ios_base::in);
template<class T>
explicit basic_istringstream(const T& t, ios_base::openmode which = ios_base::in);
template<class T>
basic_istringstream(const T& t, const Allocator& a);
template<class T>
basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a);
basic_istringstream(const basic_istringstream&) = delete;
basic_istringstream(basic_istringstream&& rhs);

Expand All @@ -8770,6 +8838,8 @@
template<class SAlloc>
void str(const basic_string<charT, traits, SAlloc>& s);
void str(basic_string<charT, traits, Allocator>&& s);
template<class T>
void str(const T& t);

private:
basic_stringbuf<charT, traits, Allocator> sb; // \expos
Expand Down Expand Up @@ -8879,6 +8949,10 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
\constraints
\tcode{is_same_v<SAlloc, Allocator>} is \tcode{false}.

\pnum
\effects
Initializes the base class with
Expand All @@ -8887,6 +8961,33 @@
\tcode{basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::in)}\iref{stringbuf.cons}.
\end{itemdescr}

\indexlibraryctor{basic_istringstream}%
\begin{itemdecl}
template<class T>
explicit basic_istringstream(const T& t, ios_base::openmode which = ios_base::in);
template<class T>
basic_istringstream(const T& t, const Allocator& a);
template<class T>
basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a);
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{which} be \tcode{ios_base::in}
for the overload with no parameter \tcode{which}, and
\tcode{a} be \tcode{Allocator()} for the overload with no parameter \tcode{a}.

\pnum
\constraints
\tcode{is_convertible_v<const T\&, basic_string_view<charT, traits>>}
is \tcode{true}.

\pnum
\effects
Initializes the base class with \tcode{addressof(sb)}, and
direct-non-list-initializes \tcode{sb} with \tcode{t, which | ios_base::in, a}.
\end{itemdescr}

\indexlibraryctor{basic_istringstream}%
\begin{itemdecl}
basic_istringstream(basic_istringstream&& rhs);
Expand Down Expand Up @@ -9018,12 +9119,30 @@
\begin{itemdecl}
void str(basic_string<charT, traits, Allocator>&& s);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{rdbuf()->str(std::move(s));}
\end{itemdescr}

\indexlibrarymember{str}{basic_istringstream}%
\begin{itemdecl}
template<class T>
void str(const T& t);
\end{itemdecl}

\begin{itemdescr}
\pnum
\constraints
\tcode{is_convertible_v<const T\&, basic_string_view<charT, traits>>}
is \tcode{true}.

\pnum
\effects
Equivalent to: \tcode{rdbuf()->str(t);}
\end{itemdescr}

\rSec2[ostringstream]{Class template \tcode{basic_ostringstream}}

\rSec3[ostringstream.general]{General}
Expand Down Expand Up @@ -9064,6 +9183,12 @@
explicit basic_ostringstream(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which = ios_base::out);
template<class T>
explicit basic_ostringstream(const T& t, ios_base::openmode which = ios_base::out);
template<class T>
basic_ostringstream(const T& t, const Allocator& a);
template<class T>
basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a);
basic_ostringstream(const basic_ostringstream&) = delete;
basic_ostringstream(basic_ostringstream&& rhs);

Expand All @@ -9086,6 +9211,8 @@
template<class SAlloc>
void str(const basic_string<charT, traits, SAlloc>& s);
void str(basic_string<charT, traits, Allocator>&& s);
template<class T>
void str(const T& t);

private:
basic_stringbuf<charT, traits, Allocator> sb; // \expos
Expand Down Expand Up @@ -9207,6 +9334,33 @@
\tcode{basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::out)}\linebreak\iref{stringbuf.cons}. % avoid Overfull
\end{itemdescr}

\indexlibraryctor{basic_ostringstream}%
\begin{itemdecl}
template<class T>
explicit basic_ostringstream(const T& t, ios_base::openmode which = ios_base::out);
template<class T>
basic_ostringstream(const T& t, const Allocator& a);
template<class T>
basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a);
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{which} be \tcode{ios_base::out}
for the overload with no parameter \tcode{which}, and
\tcode{a} be \tcode{Allocator()} for the overload with no parameter \tcode{a}.

\pnum
\constraints
\tcode{is_convertible_v<const T\&, basic_string_view<charT, traits>>}
is \tcode{true}.

\pnum
\effects
Initializes the base class with \tcode{addressof(sb)}, and
direct-non-list-initializes \tcode{sb} with \tcode{t, which | ios_base::out, a}.
\end{itemdescr}

\indexlibraryctor{basic_ostringstream}%
\begin{itemdecl}
basic_ostringstream(basic_ostringstream&& rhs);
Expand Down Expand Up @@ -9344,6 +9498,23 @@
Equivalent to: \tcode{rdbuf()->str(std::move(s));}
\end{itemdescr}

\indexlibrarymember{str}{basic_ostringstream}%
\begin{itemdecl}
template<class T>
void str(const T& t);
\end{itemdecl}

\begin{itemdescr}
\pnum
\constraints
\tcode{is_convertible_v<const T\&, basic_string_view<charT, traits>>}
is \tcode{true}.

\pnum
\effects
Equivalent to: \tcode{rdbuf()->str(t);}
\end{itemdescr}

\rSec2[stringstream]{Class template \tcode{basic_stringstream}}

\rSec3[stringstream.general]{General}
Expand Down Expand Up @@ -9384,6 +9555,13 @@
explicit basic_stringstream(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which = ios_base::out | ios_base::in);
template<class T>
explicit basic_stringstream(const T& t,
ios_base::openmode which = ios_base::out | ios_base::in);
template<class T>
basic_stringstream(const T& t, const Allocator& a);
template<class T>
basic_stringstream(const T& t, ios_base::openmode which, const Allocator& a);
basic_stringstream(const basic_stringstream&) = delete;
basic_stringstream(basic_stringstream&& rhs);

Expand All @@ -9406,6 +9584,8 @@
template<class SAlloc>
void str(const basic_string<charT, traits, SAlloc>& s);
void str(basic_string<charT, traits, Allocator>&& s);
template<class T>
void str(const T& t);

private:
basic_stringbuf<charT, traits> sb; // \expos
Expand Down Expand Up @@ -9532,6 +9712,33 @@
\tcode{basic_stringbuf<charT, traits, Allocator>(s, which)}\iref{stringbuf.cons}.
\end{itemdescr}

\indexlibraryctor{basic_stringstream}%
\begin{itemdecl}
template<class T>
explicit basic_stringstream(const T& t, ios_base::openmode which = ios_base::out | ios_base::in);
template<class T>
basic_stringstream(const T& t, const Allocator& a);
template<class T>
basic_stringstream(const T& t, ios_base::openmode which, const Allocator& a);
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{which} be \tcode{ios_base::out | ios_base::in}
for the overload with no parameter \tcode{which}, and
\tcode{a} be \tcode{Allocator()} for the overload with no parameter \tcode{a}.

\pnum
\constraints
\tcode{is_convertible_v<const T\&, basic_string_view<charT, traits>>}
is \tcode{true}.

\pnum
\effects
Initializes the base class with \tcode{addressof(sb)}, and
direct-non-list-initializes \tcode{sb} with \tcode{t, which, a}.
\end{itemdescr}

\indexlibraryctor{basic_stringstream}%
\begin{itemdecl}
basic_stringstream(basic_stringstream&& rhs);
Expand Down Expand Up @@ -9669,6 +9876,23 @@
Equivalent to: \tcode{rdbuf()->str(std::move(s));}
\end{itemdescr}

\indexlibrarymember{str}{basic_stringstream}%
\begin{itemdecl}
template<class T>
void str(const T&);
\end{itemdecl}

\begin{itemdescr}
\pnum
\constraints
\tcode{is_convertible_v<const T\&, basic_string_view<charT, traits>>}
is \tcode{true}.

\pnum
\effects
Equivalent to: \tcode{rdbuf()->str(t);}
\end{itemdescr}

\rSec1[span.streams]{Span-based streams}

\rSec2[span.streams.overview]{Overview}
Expand Down
1 change: 1 addition & 0 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@
#define @\defnlibxname{cpp_lib_span}@ 202002L // also in \libheader{span}
#define @\defnlibxname{cpp_lib_spanstream}@ 202106L // also in \libheader{spanstream}
#define @\defnlibxname{cpp_lib_ssize}@ 201902L // also in \libheader{iterator}
#define @\defnlibxname{cpp_lib_sstream_from_string_view}@ 202306L // also in \libheader{sstream}
#define @\defnlibxname{cpp_lib_stacktrace}@ 202011L // also in \libheader{stacktrace}
#define @\defnlibxname{cpp_lib_start_lifetime_as}@ 202207L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_starts_ends_with}@ 201711L // also in \libheader{string}, \libheader{string_view}
Expand Down

0 comments on commit 07f574a

Please sign in to comment.