From dbf1bd47c25376a89d88d348f8a66324f3d2bf62 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 25 Nov 2018 18:37:50 -0800 Subject: [PATCH 1/2] P1148R0 Cleaning up Clause 20 --- source/iostreams.tex | 37 +- source/strings.tex | 2274 ++++++++++++------------------------------ source/xrefdelta.tex | 13 + 3 files changed, 661 insertions(+), 1663 deletions(-) diff --git a/source/iostreams.tex b/source/iostreams.tex index 9c81dcc835..7322117919 100644 --- a/source/iostreams.tex +++ b/source/iostreams.tex @@ -162,6 +162,11 @@ \indexlibrary{\idxcode{wsyncbuf}}% \indexlibrary{\idxcode{osyncstream}}% \indexlibrary{\idxcode{wosyncstream}}% +\indexlibrary{\idxcode{fpos}}% +\indexlibrary{\idxcode{streampos}}% +\indexlibrary{\idxcode{wstreampos}}% +\indexlibrary{\idxcode{u16streampos}}% +\indexlibrary{\idxcode{u32streampos}}% \begin{codeblock} namespace std { template class char_traits; @@ -261,6 +266,8 @@ using streampos = fpos::state_type>; using wstreampos = fpos::state_type>; using u8streampos = fpos::state_type>; + using u16streampos = fpos::state_type>; + using u32streampos = fpos::state_type>; } \end{codeblock} @@ -303,9 +310,10 @@ class template specialization \tcode{basic_streambuf} serves as a base class for class templates -\tcode{basic_stringbuf} +\tcode{basic_stringbuf}, +\tcode{basic_filebuf}, and -\tcode{basic_filebuf}. +\tcode{basic_syncbuf}. \pnum The @@ -321,9 +329,10 @@ class template specialization \tcode{basic_ostream} serves as a base class for class templates -\tcode{basic_ostringstream} +\tcode{basic_ostringstream}, +\tcode{basic_ofstream}, and -\tcode{basic_ofstream}. +\tcode{basic_osyncstream}. \pnum The @@ -334,6 +343,15 @@ and \tcode{basic_fstream}. +\pnum +\begin{note} +For each of the class templates above, +the program is ill-formed if +\tcode{traits::char_type} +is not the same type as +\tcode{charT}\iref{char.traits}. +\end{note} + \pnum Other \grammarterm{typedef-name}{s} define instances of class templates @@ -368,17 +386,6 @@ \tcode{char_traits}. An implementation can avoid this circularity by substituting equivalent types. -One way to do this might be -\begin{codeblock} -template class fpos { @\commentellip@ }; // depends on nothing -using _STATE = @\commentellip@ ; // implementation private declaration of \tcode{stateT} - -using streampos = fpos<_STATE>; - -template<> struct char_traits { - using pos_type = streampos; -} -\end{codeblock} \end{note} \rSec1[iostream.objects]{Standard iostream objects} diff --git a/source/strings.tex b/source/strings.tex index 2f7ba9fef4..ffa6ebce14 100644 --- a/source/strings.tex +++ b/source/strings.tex @@ -46,7 +46,7 @@ that satisfy those requirements. \pnum -Most classes specified in \ref{string.classes} +Most classes specified in \ref{string.classes}, \ref{string.view}, and \ref{input.output} need a set of related types and functions to complete the definition of their semantics. These types and functions are provided as a set of member \grammarterm{typedef-name}{s} and functions in the template @@ -54,55 +54,42 @@ semantics of these members. \pnum -To specialize those templates to generate a string or -iostream class to handle a particular character container type -\tcode{CharT}, +To specialize those templates to generate a string, string view, or +iostream class to handle a particular character container type\iref{defns.character.container} +\tcode{C}, that and its related character traits class -\tcode{Traits} -are passed as a pair of parameters to the string or iostream template as +\tcode{X} +are passed as a pair of parameters to the string, string view, or iostream template as parameters \tcode{charT} and \tcode{traits}. -\tcode{Traits::char_type} -shall be the same as -\tcode{CharT}. - -\pnum -This subclause specifies a class template, -\tcode{char_traits}, -and five explicit specializations of it, -\tcode{char_traits<\brk{}char>}, -\tcode{char_traits}, -\tcode{char_traits}, -\tcode{char_traits}, -and -\tcode{char_traits}, -all of which appear in the header -\tcode{} -and satisfy the requirements below. +If +\tcode{X::char_type} +is not the same type as +\tcode{C}, the program is ill-formed. \rSec2[char.traits.require]{Character traits requirements} \pnum In \tref{char.traits.require}, \tcode{X} -denotes a Traits class defining types and functions for the +denotes a traits class defining types and functions for the character container type -\tcode{CharT}; +\tcode{C}; \tcode{c} and \tcode{d} denote values of type -\tcode{CharT}; +\tcode{C}; \tcode{p} and \tcode{q} denote values of type -\tcode{const CharT*}; +\tcode{const C*}; \tcode{s} denotes a value of type -\tcode{CharT*}; +\tcode{C*}; \tcode{n}, \tcode{i} and @@ -117,14 +104,11 @@ \tcode{pos} denotes a value of type \tcode{X::pos_type}; -\tcode{state} -denotes a value of type -\tcode{X::state_type}; and \tcode{r} denotes an lvalue of type -\tcode{CharT}. -Operations on Traits shall not throw exceptions. +\tcode{C}. +Operations on \tcode{X} shall not throw exceptions. \begin{libreqtab4d} {Character traits requirements} @@ -138,14 +122,14 @@ \lhdr{Expression} & \chdr{Return type} & \chdr{Assertion/note} & \rhdr{Complexity}\\ & & \chdr{pre-/post-condition} & \\ \capsep \endhead -\tcode{X::char_type} & \tcode{charT} & -(described in~\ref{char.traits.typedefs}) & compile-time \\ \rowsep +\tcode{X::char_type} & \tcode{C} & + & compile-time \\ \rowsep \tcode{X::int_type} & & (described in~\ref{char.traits.typedefs}) & compile-time \\ \rowsep \tcode{X::off_type} & & -(described in~\ref{char.traits.typedefs}) & compile-time \\ \rowsep +(described in~\ref{iostreams.limits.pos} and \ref{iostream.forward}) & compile-time \\ \rowsep \tcode{X::pos_type} & & -(described in~\ref{char.traits.typedefs}) & compile-time \\ \rowsep +(described in~\ref{iostreams.limits.pos} and \ref{iostream.forward}) & compile-time \\ \rowsep \tcode{X::state_type} & & (described in~\ref{char.traits.typedefs}) & compile-time \\ \rowsep \tcode{X::eq(c,d)} & \tcode{bool} & @@ -166,7 +150,8 @@ for each \tcode{i} in \tcode{[0,n)}, performs \tcode{X::assign(s[i],p[i])}. Copies correctly even where the ranges \tcode{[p,p+n)} and \tcode{[s,s+n)} overlap.\br \returns \tcode{s}. & linear \\ \rowsep \tcode{X::copy(s,p,n)} & \tcode{X::char_type*} & -\requires \tcode{p} not in \tcode{[s,s+n)}. \returns \tcode{s}.\br +\expects \tcode{p} not in \tcode{[s,s+n)}. \br +\returns \tcode{s}.\br for each \tcode{i} in \tcode{[0,n)}, performs \tcode{X::assign(s[i],p[i])}. & linear \\ \rowsep \tcode{X::assign(r,d)} & (not used) & @@ -204,80 +189,45 @@ template struct char_traits; \end{codeblock} -shall be provided in the header +is provided in the header \tcode{} as a basis for explicit specializations. \rSec2[char.traits.typedefs]{Traits typedefs} \indexlibrarymember{char_type}{char_traits}% -\begin{itemdecl} -using char_type = CHAR_T; -\end{itemdecl} - -\begin{itemdescr} -\pnum -The type -\tcode{char_type} -is used to refer to the character container type -in the implementation of the library classes defined in~\ref{string.classes} and \ref{input.output}. -\end{itemdescr} - \indexlibrarymember{int_type}{char_traits}% \begin{itemdecl} -using int_type = INT_T; +using int_type = @\seebelow@; \end{itemdecl} \begin{itemdescr} \pnum -\requires -For a certain character container type -\tcode{char_type}, -a related container type -\tcode{INT_T} -shall be a type or class which can represent all of the +\expects +\tcode{int_type} +shall be able to represent all of the valid characters converted from the corresponding \tcode{char_type} values, as well as an end-of-file value, -\tcode{eof()}. -The type -\tcode{int_type} -represents a character container type -which can hold end-of-file to be used as a return type -of the iostream class member functions.\footnote{If +\tcode{eof()}.% +\footnote{If \tcode{eof()} can be held in \tcode{char_type} -then some iostreams operations may give surprising results.} -\end{itemdescr} - -\indexlibrarymember{off_type}{char_traits}% -\indexlibrarymember{pos_type}{char_traits}% -\begin{itemdecl} -using off_type = @\impdef@; -using pos_type = @\impdef@; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires -Requirements for -\tcode{off_type} -and -\tcode{pos_type} -are described in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. +then some iostreams operations can give surprising results.} \end{itemdescr} \indexlibrarymember{state_type}{char_traits}% \begin{itemdecl} -using state_type = STATE_T; +using state_type = @\seebelow@; \end{itemdecl} \begin{itemdescr} \pnum \requires \tcode{state_type} -shall satisfy the +shall meet the +\oldconcept{Destructible} (\tref{destructible}), \oldconcept{CopyAssignable} (\tref{copyassignable}), \oldconcept{CopyConstructible} (\tref{copyconstructible}), and \oldconcept{DefaultConstructible} (\tref{defaultconstructible}) requirements. @@ -299,7 +249,7 @@ \pnum The header \tcode{} -shall define five +defines five specializations of the class template \tcode{char_traits}: \tcode{char_traits<\brk{}char>}, @@ -309,9 +259,6 @@ and \tcode{char_traits}. -\pnum -The requirements for the members of these specializations are given in -\ref{char.traits.require}. \rSec3[char.traits.specializations.char]{\tcode{struct char_traits}} @@ -346,35 +293,6 @@ } \end{codeblock} -\pnum -The defined types for -\tcode{int_type}, -\tcode{pos_type}, -\tcode{off_type}, -and -\tcode{state_type} -shall be -\tcode{int}, -\tcode{streampos}, -\tcode{streamoff}, -and -\tcode{mbstate_t} -respectively. - -\pnum -The type -\tcode{streampos} -shall be an \impldef{type of \tcode{streampos}} type that satisfies the requirements for -\tcode{pos_type} -in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. - -\pnum -The type -\tcode{streamoff} -shall be an \impldef{type of \tcode{streamoff}} type that satisfies the requirements for -\tcode{off_type} -in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. - \pnum The type \tcode{mbstate_t} @@ -385,15 +303,15 @@ character encoding rules. \pnum -The two-argument member \tcode{assign} shall be defined identically to the +The two-argument member \tcode{assign} is defined identically to the built-in operator \tcode{=}. The two-argument members \tcode{eq} -and \tcode{lt} shall be defined identically to the built-in operators +and \tcode{lt} are defined identically to the built-in operators \tcode{==} and \tcode{<} for type \tcode{unsigned char}. \pnum The member \tcode{eof()} -shall return +returns \tcode{EOF}. \rSec3[char.traits.specializations.char8_t]{\tcode{struct char_traits}} @@ -470,20 +388,15 @@ } \end{codeblock} -\pnum -The type -\tcode{u16streampos} -shall be an \impldef{type of \tcode{u16streampos}} type that satisfies the requirements -for \tcode{pos_type} in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. \pnum The two-argument members \tcode{assign}, -\tcode{eq}, and \tcode{lt} shall be defined identically to +\tcode{eq}, and \tcode{lt} are defined identically to the built-in operators \tcode{=}, \tcode{==}, and -\tcode{<} respectively. +\tcode{<}, respectively. \pnum -The member \tcode{eof()} shall return an +The member \tcode{eof()} returns an \impldef{return value of \tcode{char_traits::eof}} constant that cannot appear as a valid UTF-16 code unit. @@ -520,20 +433,15 @@ } \end{codeblock} -\pnum -The type -\tcode{u32streampos} -shall be an \impldef{type of \tcode{u32streampos}} type that satisfies the requirements -for \tcode{pos_type} in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. \pnum The two-argument members \tcode{assign}, -\tcode{eq}, and \tcode{lt} shall be defined identically to +\tcode{eq}, and \tcode{lt} are defined identically to the built-in operators \tcode{=}, \tcode{==}, and -\tcode{<} respectively. +\tcode{<}, respectively. \pnum -The member \tcode{eof()} shall return an +The member \tcode{eof()} returns an \impldef{return value of \tcode{char_traits::eof}} constant that cannot appear as a Unicode code point. @@ -570,32 +478,6 @@ } \end{codeblock} -\pnum -The defined types for -\tcode{int_type}, -\tcode{pos_type}, -and -\tcode{state_type} -shall be -\tcode{wint_t}, -\tcode{wstreampos}, -and -\tcode{mbstate_t} -respectively. - -\pnum -The type -\tcode{wstreampos} -shall be an \impldef{type of \tcode{wstreampos}} type that satisfies the requirements -for \tcode{pos_type} in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. - -\pnum -The type -\tcode{mbstate_t} -is defined in -\tcode{} -and can represent any of the conversion states that can occur in an \impldef{supported -multibyte character encoding rules} set of supported multibyte character encoding rules. \pnum The two-argument members @@ -603,18 +485,18 @@ \tcode{eq}, and \tcode{lt} -shall be defined identically +are defined identically to the built-in operators \tcode{=}, \tcode{==}, and -\tcode{<} +\tcode{<}, respectively. \pnum The member \tcode{eof()} -shall return +returns \tcode{WEOF}. \rSec1[string.classes]{String classes} @@ -893,16 +775,7 @@ is designated by \tcode{charT}. \pnum -The -member functions of -\tcode{basic_string} use an object of the -\tcode{Allocator} -class passed as a template parameter to allocate and free storage for the -contained char-like objects.\footnote{\tcode{Allocator::value_type} must name the same type -as \tcode{charT}\iref{string.require}.} - -\pnum -A \tcode{basic_string} is a contiguous container\iref{container.requirements.general}. +A specialization of \tcode{basic_string} is a contiguous container\iref{container.requirements.general}. \pnum In all cases, @@ -911,24 +784,6 @@ (a ``null terminator''\indextext{string!null terminator}), and \tcode{size() <= capacity()} is \tcode{true}. -\pnum -The functions described in this Clause can report two -kinds of errors, each associated with an exception type: - -\begin{itemize} -\item -a -\term{length} -error is associated with exceptions of type -\tcode{length_error}\iref{length.error}; -\indexlibrary{\idxcode{length_error}}% -\item -an -\term{out-of-range} -error is associated with exceptions of type -\tcode{out_of_range}\iref{out.of.range}. -\indexlibrary{\idxcode{out_of_range}}% -\end{itemize} \indexlibrary{\idxcode{basic_string}}% \indexlibrarymember{traits_type}{basic_string}% @@ -1135,47 +990,47 @@ allocator_type get_allocator() const noexcept; template - size_type find (const T& t, size_type pos = 0) const; + size_type find (const T& t, size_type pos = 0) const noexcept(@\seebelow@); size_type find (const basic_string& str, size_type pos = 0) const noexcept; size_type find (const charT* s, size_type pos, size_type n) const; size_type find (const charT* s, size_type pos = 0) const; - size_type find (charT c, size_type pos = 0) const; + size_type find (charT c, size_type pos = 0) const noexcept; template - size_type rfind(const T& t, size_type pos = npos) const; + size_type rfind(const T& t, size_type pos = npos) const noexcept(@\seebelow@); size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; size_type rfind(const charT* s, size_type pos, size_type n) const; size_type rfind(const charT* s, size_type pos = npos) const; - size_type rfind(charT c, size_type pos = npos) const; + size_type rfind(charT c, size_type pos = npos) const noexcept; template - size_type find_first_of(const T& t, size_type pos = 0) const; + size_type find_first_of(const T& t, size_type pos = 0) const noexcept(@\seebelow@); size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; size_type find_first_of(const charT* s, size_type pos, size_type n) const; size_type find_first_of(const charT* s, size_type pos = 0) const; - size_type find_first_of(charT c, size_type pos = 0) const; + size_type find_first_of(charT c, size_type pos = 0) const noexcept; template - size_type find_last_of (const T& t, size_type pos = npos) const; + size_type find_last_of (const T& t, size_type pos = npos) const noexcept(@\seebelow@); size_type find_last_of (const basic_string& str, size_type pos = npos) const noexcept; size_type find_last_of (const charT* s, size_type pos, size_type n) const; size_type find_last_of (const charT* s, size_type pos = npos) const; - size_type find_last_of (charT c, size_type pos = npos) const; + size_type find_last_of (charT c, size_type pos = npos) const noexcept; template - size_type find_first_not_of(const T& t, size_type pos = 0) const; + size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept(@\seebelow@); size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; size_type find_first_not_of(const charT* s, size_type pos = 0) const; - size_type find_first_not_of(charT c, size_type pos = 0) const; + size_type find_first_not_of(charT c, size_type pos = 0) const noexcept; template - size_type find_last_not_of (const T& t, size_type pos = npos) const; + size_type find_last_not_of (const T& t, size_type pos = npos) const noexcept(@\seebelow@); size_type find_last_not_of (const basic_string& str, size_type pos = npos) const noexcept; size_type find_last_not_of (const charT* s, size_type pos, size_type n) const; size_type find_last_not_of (const charT* s, size_type pos = npos) const; - size_type find_last_not_of (charT c, size_type pos = npos) const; + size_type find_last_not_of (charT c, size_type pos = npos) const noexcept; basic_string substr(size_type pos = 0, size_type n = npos) const; template - int compare(const T& t) const; + int compare(const T& t) const noexcept(@\seebelow@); template int compare(size_type pos1, size_type n1, const T& t) const; template @@ -1230,25 +1085,28 @@ \pnum If any operation would cause \tcode{size()} to -exceed \tcode{max_size()}, that operation shall throw an +exceed \tcode{max_size()}, that operation throws an exception object of type \tcode{length_error}. \pnum If any member function or operator of \tcode{basic_string} throws an exception, that -function or operator shall have no other effect. +function or operator has no other effect on the \tcode{basic_string} object. \pnum In every specialization \tcode{basic_string}, the type \tcode{allocator_traits::value_type} shall name the same type as \tcode{charT}. Every object of type -\tcode{basic_string} shall use an object of type +\tcode{basic_string} uses an object of type \tcode{Allocator} to allocate and free storage for the contained \tcode{charT} -objects as needed. The \tcode{Allocator} object used shall be +objects as needed. The \tcode{Allocator} object used is obtained as described in \ref{container.requirements.general}. In every specialization \tcode{basic_string}, the type \tcode{traits} shall satisfy -the character traits requirements\iref{char.traits}, and -the type \tcode{traits::char_type} shall name the same type as \tcode{charT}. +the character traits requirements\iref{char.traits}. +\begin{note} +The program is ill-formed if \tcode{traits::char_type} +is not the same type as \tcode{charT}. +\end{note} \pnum References, pointers, and iterators referring to the elements of a @@ -1256,7 +1114,7 @@ invalidated by the following uses of that \tcode{basic_string} object: \begin{itemize} -\item as an argument to any standard library function taking a reference to non-const +\item Passing as an argument to any standard library function taking a reference to non-const \tcode{basic_string} as an argument.\footnote{For example, as an argument to non-member functions \tcode{swap()}\iref{string.special}, \tcode{operator>{}>()}\iref{string.io}, and \tcode{getline()}\iref{string.io}, or as @@ -1283,13 +1141,10 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\effects -Constructs an object of class \tcode{basic_string}. \pnum \ensures -\tcode{size()} is \tcode{0} and \tcode{capacity()} is an unspecified value. +\tcode{size()} is equal to \tcode{0}. \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1301,16 +1156,12 @@ \begin{itemdescr} \pnum \effects -Constructs an object of class \tcode{basic_string}. +Constructs an object whose +value is that of \tcode{str} prior to this call. \pnum -\ensures -\tcode{data()} points at the first element of an allocated copy -of the array whose first element is pointed at by the original -value \tcode{str.data()}, \tcode{size()} is equal to the -original value of \tcode{str.size()}, and \tcode{capacity()} is a value -at least as large as \tcode{size()}. -In the second form, \tcode{str} is left in a valid state with an unspecified value. +\remarks +In the second form, \tcode{str} is left in a valid but unspecified state. \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1322,26 +1173,12 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\throws -\tcode{out_of_range} -if -\tcode{pos > str.size()}. - \pnum \effects -Constructs an object of class -\tcode{basic_string} -and determines the effective length \tcode{rlen} of the initial string -value as \tcode{str.size() - pos} in the first form and -as the smaller of \tcode{str.size() - pos} and \tcode{n} in the second form. - -\pnum -\ensures -\tcode{data()} points at the first element of an allocated copy of \tcode{rlen} -consecutive elements of the string controlled by \tcode{str} beginning at position -\tcode{pos}, \tcode{size()} is equal to \tcode{rlen}, and \tcode{capacity()} is a -value at least as large as \tcode{size()}. +Let \tcode{n} be \tcode{npos} for the first overload. Equivalent to: +\begin{codeblock} +basic_string(basic_string_view(str).substr(pos, n), a) +\end{codeblock} \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1351,6 +1188,11 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\tcode{is_convertible_v>} +is \tcode{true}. + \pnum \effects Creates a variable, \tcode{sv}, as if by \tcode{basic_string_view sv = t;} @@ -1358,11 +1200,6 @@ \begin{codeblock} basic_string(sv.substr(pos, n), a); \end{codeblock} - -\pnum -\remarks This constructor shall not participate in overload resolution -unless \tcode{is_convertible_v>} -is \tcode{true}. \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1372,17 +1209,21 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} + \pnum \effects Creates a variable, \tcode{sv}, as if by \tcode{basic_string_view sv = t;} and then behaves the same as \tcode{basic_string(sv.data(), sv.size(), a)}. - -\pnum -\remarks This constructor shall not participate in overload resolution unless -\begin{itemize} -\item \tcode{is_convertible_v>} is \tcode{true} and -\item \tcode{is_convertible_v} is \tcode{false}. -\end{itemize} \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1392,21 +1233,16 @@ \begin{itemdescr} \pnum -\requires -\tcode{s} points to an array of at least \tcode{n} elements of \tcode{charT}. +\expects \range{s}{s + n} is a valid range. \pnum \effects -Constructs an object of class \tcode{basic_string} -and determines its initial string value from the array of -\tcode{charT} of length \tcode{n} whose first element is designated by \tcode{s}. +Constructs an object whose initial value is the range \range{s}{s + n}. \pnum \ensures -\tcode{data()} points at the first element of an allocated copy -of the array whose first element is pointed at by \tcode{s}, -\tcode{size()} is equal to \tcode{n}, and \tcode{capacity()} is -a value at least as large as \tcode{size()}. +\tcode{size()} is equal to \tcode{n}, and +\tcode{traits::compare(data(), s, n)} is equal to \tcode{0}. \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1416,32 +1252,15 @@ \begin{itemdescr} \pnum -\requires -\tcode{s} points to an array of at least \tcode{traits::length(s) + 1} elements -of \tcode{charT}. - -\pnum -\effects -Constructs an object of class \tcode{basic_string} -and determines its initial string value from the array of -\tcode{charT} of length \tcode{traits::length(s)} -whose first element is designated by \tcode{s}. - -\pnum -\ensures -\tcode{data()} points at the first element of an allocated copy -of the array whose first element is pointed at by \tcode{s}, -\tcode{size()} is equal to \tcode{traits::length(s)}, and -\tcode{capacity()} is a value at least as large as \tcode{size()}. - -\pnum -\remarks -Shall not participate in overload resolution -if \tcode{Allocator} is a type -that does not qualify as an allocator\iref{container.requirements.general}. +\constraints +\tcode{Allocator} is a type +that qualifies as an allocator\iref{container.requirements.general}. \begin{note} This affects class template argument deduction. \end{note} + +\pnum +\effects Equivalent to: \tcode{basic_string(s, traits::length(s), a)}. \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1451,30 +1270,16 @@ \begin{itemdescr} \pnum -\requires -\tcode{n < npos}. - -\pnum -\effects -Constructs an object of class \tcode{basic_string} -and determines its initial string value by repeating the char-like -object \tcode{c} for all \tcode{n} elements. - -\pnum -\ensures -\tcode{data()} points at the first element of an allocated array -of \tcode{n} elements, each storing the initial value \tcode{c}, -\tcode{size()} is equal to \tcode{n}, and -\tcode{capacity()} is a value at least as large as \tcode{size()}. - -\pnum -\remarks -Shall not participate in overload resolution -if \tcode{Allocator} is a type -that does not qualify as an allocator\iref{container.requirements.general}. +\constraints +\tcode{Allocator} is a type +that qualifies as an allocator\iref{container.requirements.general}. \begin{note} This affects class template argument deduction. \end{note} + +\pnum +\effects +Constructs an object whose value consists of \tcode{n} copies of \tcode{c}. \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1484,17 +1289,15 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\tcode{InputIterator} is a type that qualifies as an input +iterator\iref{container.requirements.general}. + \pnum \effects -If \tcode{InputIterator} is an integral type, -equivalent to: -\begin{codeblock} -basic_string(static_cast(begin), static_cast(end), a); -\end{codeblock} -Otherwise constructs a string from the values in the range [\tcode{begin}, \tcode{end}), -as indicated in the Sequence Requirements table -(see~\ref{sequence.reqmts}). -% +Constructs a string from the values in the range \range{begin}{end}, +as indicated in \tref{containers.sequence.requirements}. \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1504,7 +1307,7 @@ \begin{itemdescr} \pnum -\effects Same as \tcode{basic_string(il.begin(), il.end(), a)}. +\effects Equivalent to \tcode{basic_string(il.begin(), il.end(), a)}. \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1515,19 +1318,10 @@ \begin{itemdescr} \pnum -\effects Constructs an object of class \tcode{basic_string}. +\effects Constructs an object whose value is +that of \tcode{str} prior to this call. The stored allocator is constructed from \tcode{alloc}. - -\pnum -\ensures -\tcode{data()} points at the first element of an allocated copy -of the array whose first element is pointed at by the original -value of \tcode{str.data()}, \tcode{size()} is equal to the -original value of \tcode{str.size()}, \tcode{capacity()} is a value -at least as large as \tcode{size()}, and \tcode{get_allocator()} is -equal to \tcode{alloc}. -In the second form, \tcode{str} is left in a valid state with an -unspecified value. +In the second form, \tcode{str} is left in a valid but unspecified state. \pnum \throws The second form throws nothing if \tcode{alloc == str.get_allocator()}. @@ -1544,9 +1338,9 @@ \begin{itemdescr} \pnum -\remarks Shall not participate in overload resolution if -\tcode{InputIterator} is a type that does not qualify as an input iterator, -or if \tcode{Allocator} is a type that does not qualify as an allocator\iref{container.requirements.general}. +\constraints +\tcode{InputIterator} is a type that qualifies as an input iterator, +and \tcode{Allocator} is a type that qualifies as an allocator\iref{container.requirements.general}. \end{itemdescr} \begin{itemdecl} @@ -1567,8 +1361,8 @@ \begin{itemdescr} \pnum -\remarks Shall not participate in overload resolution if -\tcode{Allocator} is a type that does not qualify as +\constraints +\tcode{Allocator} is a type that qualifies as an allocator\iref{container.requirements.general}. \end{itemdescr} @@ -1579,17 +1373,13 @@ \begin{itemdescr} \pnum -\returns -\tcode{*this}. +\effects +If \tcode{*this} and \tcode{str} are the same object, has no effect. +Otherwise, replaces the value of \tcode{*this} with a copy of \tcode{str}. \pnum -\ensures -If \tcode{*this} and \tcode{str} are the same object, the member has no effect. -Otherwise, -\tcode{data()} points at the first element of an allocated copy -of the array whose first element is pointed at by \tcode{str.data()}, -\tcode{size()} is equal to \tcode{str.size()}, and -\tcode{capacity()} is a value at least as large as \tcode{size()}. +\returns +\tcode{*this}. \end{itemdescr} \indexlibrarymember{operator=}{basic_string}% @@ -1617,19 +1407,21 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\begin{itemize} +\item \tcode{is_convertible_v>} +is \tcode{true} and +\item \tcode{is_convertible_v} +is \tcode{false}. +\end{itemize} + \pnum \effects Equivalent to: \begin{codeblock} -{ - basic_string_view sv = t; - return assign(sv); -} +basic_string_view sv = t; +return assign(sv); \end{codeblock} - -\pnum -\remarks This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{operator=}{basic_string}% @@ -1639,14 +1431,8 @@ \begin{itemdescr} \pnum -\returns -\tcode{*this = basic_string(s)}. - -\pnum -\remarks -Uses -\indexlibrary{\idxcode{length}!\idxcode{char_traits}}% -\tcode{traits::length()}. +\effects Equivalent to: +\tcode{return *this = basic_string_view(s);} \end{itemdescr} \indexlibrarymember{operator=}{basic_string}% @@ -1656,8 +1442,10 @@ \begin{itemdescr} \pnum -\returns -\tcode{*this = basic_string(1, c)}. +\effects Equivalent to: +\begin{codeblock} +return *this = basic_string_view(addressof(c), 1); +\end{codeblock} \end{itemdescr} \indexlibrarymember{operator=}{basic_string}% @@ -1667,10 +1455,10 @@ \begin{itemdescr} \pnum -\effects As if by: \tcode{*this = basic_string(il);} - -\pnum -\returns \tcode{*this}. +\effects Equivalent to: +\begin{codeblock} +return *this = basic_string_view(il.begin(), il.size()); +\end{codeblock} \end{itemdescr} \rSec3[string.iterators]{Iterator support} @@ -1736,8 +1524,10 @@ \rSec3[string.capacity]{Capacity} \indexlibrarymember{size}{basic_string}% +\indexlibrarymember{length}{basic_string}% \begin{itemdecl} size_type size() const noexcept; +size_type length() const noexcept; \end{itemdecl} \begin{itemdescr} @@ -1749,17 +1539,6 @@ \complexity Constant time. \end{itemdescr} -\indexlibrarymember{length}{basic_string}% -\begin{itemdecl} -size_type length() const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{size()}. -\end{itemdescr} - \indexlibrarymember{max_size}{basic_string}% \begin{itemdecl} size_type max_size() const noexcept; @@ -1781,15 +1560,9 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\throws -\tcode{length_error} -if -\tcode{n > max_size()}. - \pnum \effects -Alters the length of the string designated by +Alters the value of \tcode{*this} as follows: @@ -1797,21 +1570,11 @@ \item If \tcode{n <= size()}, -the function replaces the string designated by -\tcode{*this} -with a string of length \tcode{n} whose elements are a -copy of the initial elements of the original string designated by -\tcode{*this}. +erases the last \tcode{size() - n} elements. \item If \tcode{n > size()}, -the function replaces the string designated by -\tcode{*this} -with a string of length \tcode{n} whose first -\tcode{size()} -elements are a copy of the original string designated by -\tcode{*this}, -and whose remaining elements are all initialized to \tcode{c}. +appends \tcode{n - size()} copies of \tcode{c}. \end{itemize} \end{itemdescr} @@ -1823,7 +1586,7 @@ \begin{itemdescr} \pnum \effects -As if by \tcode{resize(n, charT())}. +Equivalent to \tcode{resize(n, charT())}. \end{itemdescr} \indexlibrarymember{capacity}{basic_string}% @@ -1866,10 +1629,8 @@ \throws \tcode{length_error} if -\tcode{res_arg > max_size()}.\footnote{\tcode{reserve()} -uses -\tcode{allocator_traits::allocate()} -which may throw an appropriate exception.} +\tcode{res_arg > max_size()} or any exceptions thrown by +\tcode{allocator_traits} \tcode{::allocate}. \end{itemdescr} \indexlibrarymember{shrink_to_fit}{basic_string}% @@ -1902,11 +1663,7 @@ \begin{itemdescr} \pnum \effects -Behaves as if the function calls: - -\begin{codeblock} -erase(begin(), end()); -\end{codeblock} +Equivalent to: \tcode{erase(begin(), end());} \end{itemdescr} \indexlibrarymember{empty}{basic_string}% @@ -1916,8 +1673,8 @@ \begin{itemdescr} \pnum -\returns -\tcode{size() == 0}. +\effects Equivalent to: +\tcode{return size() == 0;} \end{itemdescr} \rSec3[string.access]{Element access} @@ -1930,7 +1687,7 @@ \begin{itemdescr} \pnum -\requires \tcode{pos <= size()}. +\expects \tcode{pos <= size()}. \pnum \returns \tcode{*(begin() + pos)} if \tcode{pos < size()}. Otherwise, @@ -1971,7 +1728,7 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{!empty()}. \pnum @@ -1987,7 +1744,7 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{!empty()}. \pnum @@ -2006,11 +1763,9 @@ \begin{itemdescr} \pnum -\effects Calls \tcode{append(str)}. +\effects Equivalent to: \tcode{return append(str);} + -\pnum -\returns -\tcode{*this}. \end{itemdescr} \indexlibrarymember{operator+=}{basic_string}% @@ -2021,20 +1776,23 @@ \begin{itemdescr} \pnum -\effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and -then calls \tcode{append(sv)}. - -\pnum -\returns -\tcode{*this}. +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} \pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. +\effects +Equivalent to: +\begin{codeblock} +basic_string_view sv = t; +return append(sv); +\end{codeblock} \end{itemdescr} \indexlibrarymember{operator+=}{basic_string}% @@ -2044,11 +1802,7 @@ \begin{itemdescr} \pnum -\effects Calls \tcode{append(s)}. - -\pnum -\returns -\tcode{*this}. +\effects Equivalent to: \tcode{return append(s);} \end{itemdescr} \indexlibrarymember{operator+=}{basic_string}% @@ -2058,11 +1812,7 @@ \begin{itemdescr} \pnum -\effects Calls \tcode{push_back(c)}; - -\pnum -\returns -\tcode{*this}. +\effects Equivalent to: \tcode{return append(size_type\{1\}, c);} \end{itemdescr} \indexlibrarymember{operator+=}{basic_string}% @@ -2072,10 +1822,7 @@ \begin{itemdescr} \pnum -\effects Calls \tcode{append(il)}. - -\pnum -\returns \tcode{*this}. +\effects Equivalent to: \tcode{return append(il);} \end{itemdescr} @@ -2088,11 +1835,7 @@ \begin{itemdescr} \pnum -\effects Calls \tcode{append(str.data(), str.size())}. - -\pnum -\returns -\tcode{*this}. +\effects Equivalent to: \tcode{return append(str.data(), str.size());} \end{itemdescr} \indexlibrarymember{append}{basic_string}% @@ -2101,21 +1844,12 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\throws -\tcode{out_of_range} -if -\tcode{pos > str.size()}. - \pnum \effects -Determines the effective length \tcode{rlen} -of the string to append as the smaller of \tcode{n} and -\tcode{\tcode{str}.size() - \tcode{pos}} and calls \tcode{append(str.data() + pos, rlen)}. - -\pnum -\returns -\tcode{*this}. +Equivalent to: +\begin{codeblock} +return append(basic_string_view(str).substr(pos, n)); +\end{codeblock} \end{itemdescr} \indexlibrarymember{append}{basic_string}% @@ -2126,20 +1860,23 @@ \begin{itemdescr} \pnum -\effects -Equivalent to: -\begin{codeblock} -{ - basic_string_view sv = t; - return append(sv.data(), sv.size()); -} -\end{codeblock} +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} \pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. +\effects +Equivalent to: +\begin{codeblock} +basic_string_view sv = t; +return append(sv.data(), sv.size()); +\end{codeblock} \end{itemdescr} \indexlibrarymember{append}{basic_string}% @@ -2150,27 +1887,23 @@ \begin{itemdescr} \pnum -\throws -\tcode{out_of_range} -if -\tcode{pos > sv.size()}. +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} \pnum \effects -Creates a variable, \tcode{sv}, as if by \tcode{basic_string_view sv = t}. -Determines the effective length \tcode{rlen} of the string to append -as the smaller of \tcode{n} and \tcode{sv.size() - pos} -and calls \tcode{append(sv.data() + pos, rlen)}. - -\pnum -\remarks -This function shall not participate in overload resolution -unless \tcode{is_convertible_v>} -is \tcode{true} and \tcode{is_convertible_v} is \tcode{false}. - -\pnum -\returns -\tcode{*this}. +Equivalent to: +\begin{codeblock} +basic_string_view sv = t; +return append(sv.substr(pos, n)); +\end{codeblock} \end{itemdescr} \indexlibrarymember{append}{basic_string}% @@ -2180,18 +1913,10 @@ \begin{itemdescr} \pnum -\requires \tcode{s} points to an array of at least \tcode{n} elements -of \tcode{charT}. - -\pnum -\throws \tcode{length_error} if \tcode{size() + n > max_size()}. +\expects \range{s}{s + n} is a valid range. \pnum -\effects The function replaces the string controlled by \tcode{*this} -with a string of length \tcode{size() + n} whose first \tcode{size()} -elements are a copy of the original string controlled by \tcode{*this} -and whose remaining elements are a copy of the initial \tcode{n} elements -of \tcode{s}. +\effects Appends a copy of the range \range{s}{s + n} to the string. \pnum \returns @@ -2205,15 +1930,7 @@ \begin{itemdescr} \pnum -\requires \tcode{s} points to an array of at least \tcode{traits::length(s) + 1} -elements of \tcode{charT}. - -\pnum -\effects Calls \tcode{append(s, traits::length(s))}. - -\pnum -\returns -\tcode{*this}. +\effects Equivalent to: \tcode{return append(s, traits::length(s));} \end{itemdescr} \indexlibrarymember{append}{basic_string}% @@ -2223,7 +1940,10 @@ \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return append(basic_string(n, c));} +\effects Appends \tcode{n} copies of \tcode{c} to the string. + +\pnum +\returns \tcode{*this}. \end{itemdescr} \indexlibrarymember{append}{basic_string}% @@ -2234,7 +1954,9 @@ \begin{itemdescr} \pnum -\requires \range{first}{last} is a valid range. +\constraints +\tcode{InputIterator} is a type that qualifies as an input +iterator\iref{container.requirements.general}. \pnum \effects Equivalent to: \tcode{return append(basic_string(first, last, get_allocator()));} @@ -2247,11 +1969,7 @@ \begin{itemdescr} \pnum -\effects Calls \tcode{append(il.begin(), il.size())}. - -\pnum -\returns -\tcode{*this}. +\effects Equivalent to: \tcode{return append(il.begin(), il.size());} \end{itemdescr} \indexlibrarymember{push_back}{basic_string}% @@ -2263,7 +1981,7 @@ \pnum \effects Equivalent to -\tcode{append(static_cast(1), c)}. +\tcode{append(size_type\{1\}, c)}. \end{itemdescr} \rSec4[string.assign]{\tcode{basic_string::assign}} @@ -2297,22 +2015,12 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\throws -\tcode{out_of_range} -if -\tcode{pos > str.size()}. - \pnum \effects -Determines the effective length \tcode{rlen} -of the string to assign as the smaller of \tcode{n} and -\tcode{\tcode{str}.size() - \tcode{pos}} and calls -\tcode{assign(str.data() + pos, rlen)}. - -\pnum -\returns -\tcode{*this}. +Equivalent to: +\begin{codeblock} +return assign(basic_string_view(str).substr(pos, n)); +\end{codeblock} \end{itemdescr} \indexlibrarymember{assign}{basic_string}% @@ -2322,21 +2030,24 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} + \pnum \effects Equivalent to: \begin{codeblock} -{ - basic_string_view sv = t; - return assign(sv.data(), sv.size()); -} +basic_string_view sv = t; +return assign(sv.data(), sv.size()); \end{codeblock} - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{assign}{basic_string}% @@ -2347,27 +2058,22 @@ \begin{itemdescr} \pnum -\throws -\tcode{out_of_range} -if -\tcode{pos > sv.size()}. - -\pnum -\effects -Creates a variable, \tcode{sv}, as if by \tcode{basic_string_view sv = t}. -Determines the effective length \tcode{rlen} of the string to assign -as the smaller of \tcode{n} and \tcode{sv.size() - pos} -and calls \tcode{assign(sv.data() + pos, rlen)}. - -\pnum -\remarks -This function shall not participate in overload resolution -unless \tcode{is_convertible_v>} -is \tcode{true} and \tcode{is_convertible_v} is \tcode{false}. +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} \pnum -\returns -\tcode{*this}. +\effects Equivalent to: +\begin{codeblock} +basic_string_view sv = t; +return assign(sv.substr(pos, n)); +\end{codeblock} \end{itemdescr} \indexlibrarymember{assign}{basic_string}% @@ -2377,14 +2083,12 @@ \begin{itemdescr} \pnum -\requires \tcode{s} points to an array of at least \tcode{n} elements of \tcode{charT}. +\expects \range{s}{s + n} is a valid range. \pnum -\throws \tcode{length_error} if \tcode{n > max_size()}. - -\pnum -\effects Replaces the string controlled by \tcode{*this} with a string -of length \tcode{n} whose elements are a copy of those pointed to by \tcode{s}. +\effects +Replaces the string controlled by \tcode{*this} with +a copy of the range \range{s}{s + n}. \pnum \returns @@ -2398,15 +2102,7 @@ \begin{itemdescr} \pnum -\requires \tcode{s} points to an array of at least \tcode{traits::length(s) + 1} -elements of \tcode{charT}. - -\pnum -\effects Calls \tcode{assign(s, traits::length(s))}. - -\pnum -\returns -\tcode{*this}. +\effects Equivalent to: \tcode{return assign(s, traits::length(s));} \end{itemdescr} \indexlibrarymember{assign}{basic_string}% @@ -2416,14 +2112,9 @@ \begin{itemdescr} \pnum -\effects Calls \tcode{assign(il.begin(), il.size())}. - -\pnum -\returns -\tcode{*this}. +\effects Equivalent to: \tcode{return assign(il.begin(), il.size());} \end{itemdescr} - \indexlibrarymember{assign}{basic_string}% \begin{itemdecl} basic_string& assign(size_type n, charT c); @@ -2431,7 +2122,12 @@ \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return assign(basic_string(n, c));} +\effects Equivalent to: +\begin{codeblock} +clear(); +resize(n, c); +return *this; +\end{codeblock} \end{itemdescr} \indexlibrarymember{assign}{basic_string}% @@ -2441,6 +2137,11 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\tcode{InputIterator} is a type that qualifies as an input +iterator\iref{container.requirements.general}. + \pnum \effects Equivalent to: \tcode{return assign(basic_string(first, last, get_allocator()));} \end{itemdescr} @@ -2463,23 +2164,12 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\throws -\tcode{out_of_range} -if -\tcode{pos1 > size()} -or -\tcode{pos2 > str.size()}. - \pnum \effects -Determines the effective length \tcode{rlen} of the string to insert as the smaller -of \tcode{n} and -\tcode{str.size() - pos2} and calls \tcode{insert(pos1, str.data() + pos2, rlen)}. - -\pnum -\returns -\tcode{*this}. +Equivalent to: +\begin{codeblock} +return insert(pos1, basic_string_view(str), pos2, n); +\end{codeblock} \end{itemdescr} \indexlibrarymember{insert}{basic_string}% @@ -2489,21 +2179,24 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} + \pnum \effects Equivalent to: \begin{codeblock} -{ - basic_string_view sv = t; - return insert(pos, sv.data(), sv.size()); -} +basic_string_view sv = t; +return insert(pos, sv.data(), sv.size()); \end{codeblock} - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{insert}{basic_string}% @@ -2514,29 +2207,22 @@ \begin{itemdescr} \pnum -\throws -\tcode{out_of_range} -if -\tcode{pos1 > size()} -or -\tcode{pos2 > sv.size()}. - -\pnum -\effects -Creates a variable, \tcode{sv}, as if by \tcode{basic_string_view sv = t}. -Determines the effective length \tcode{rlen} of the string to assign -as the smaller of \tcode{n} and \tcode{sv.size() - pos2} -and calls \tcode{insert(pos1, sv.data() + pos2, rlen)}. - -\pnum -\remarks -This function shall not participate in overload resolution -unless \tcode{is_convertible_v>} -is \tcode{true} and \tcode{is_convertible_v} is \tcode{false}. +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} \pnum -\returns -\tcode{*this}. +\effects Equivalent to: +\begin{codeblock} +basic_string_view sv = t; +return insert(pos1, sv.substr(pos2, n)); +\end{codeblock} \end{itemdescr} \indexlibrarymember{insert}{basic_string}% @@ -2546,20 +2232,20 @@ \begin{itemdescr} \pnum -\requires \tcode{s} points to an array of at least \tcode{n} -elements of \tcode{charT}. +\expects \range{s}{s + n} is a valid range. \pnum -\throws \tcode{out_of_range} if \tcode{pos > size()} or \tcode{length_error} -if \tcode{size() + n > max_size()}. +\throws +\begin{itemize} +\item \tcode{out_of_range} if \tcode{pos > size()}, +\item \tcode{length_error} if \tcode{n > max_size() - size()}, or +\item any exceptions thrown by \tcode{allocator_traits::allocate}. +\end{itemize} \pnum -\effects Replaces the string controlled by \tcode{*this} with a string of -length \tcode{size() + n} whose first \tcode{pos} elements are a copy of -the initial elements of the original string controlled by \tcode{*this} and -whose next \tcode{n} elements are a copy of the elements in \tcode{s} and -whose remaining elements are a copy of the remaining elements of the original -string controlled by \tcode{*this}. +\effects Inserts a copy of the range \range{s}{s + n} +immediately before the character at position \tcode{pos} if \tcode{pos < size()}, +or otherwise at the end of the string. \pnum \returns @@ -2572,10 +2258,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\requires \tcode{s} points to an array of at least -\tcode{traits::length(s) + 1} elements of \tcode{charT}. - \pnum \effects Equivalent to: \tcode{return insert(pos, s, traits::length(s));} \end{itemdescr} @@ -2587,7 +2269,17 @@ \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return insert(pos, basic_string(n, c));} +\throws +\begin{itemize} +\item \tcode{out_of_range} if \tcode{pos > size()}, +\item \tcode{length_error} if \tcode{n > max_size() - size()}, or +\item any exceptions thrown by \tcode{allocator_traits::allocate}. +\end{itemize} +\pnum +\effects +Inserts \tcode{n} copies of \tcode{c} before the character at position \tcode{pos} +if \tcode{pos < size()}, +or otherwise at the end of the string. \end{itemdescr} \indexlibrarymember{insert}{basic_string}% @@ -2597,17 +2289,17 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{p} is a valid iterator on \tcode{*this}. \pnum \effects -Inserts a copy of \tcode{c} before the character referred to by \tcode{p}. +Inserts a copy of \tcode{c} at the position \tcode{p}. \pnum \returns -An iterator which refers to the copy of the inserted character. +An iterator which refers to the inserted character. \end{itemdescr} \indexlibrarymember{insert}{basic_string}% @@ -2617,16 +2309,16 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{p} is a valid iterator on \tcode{*this}. \pnum \effects -Inserts \tcode{n} copies of \tcode{c} before the character referred to by \tcode{p}. +Inserts \tcode{n} copies of \tcode{c} at the position \tcode{p}. \pnum -\returns An iterator which refers to the copy of the first inserted character, or +\returns An iterator which refers to the first inserted character, or \tcode{p} if \tcode{n == 0}. \end{itemdescr} @@ -2638,11 +2330,14 @@ \begin{itemdescr} \pnum -\requires +\constraints +\tcode{InputIterator} is a type that qualifies as an input +iterator\iref{container.requirements.general}. + +\pnum +\expects \tcode{p} is a valid iterator on \tcode{*this}. -\tcode{[first, last)} -is a valid range. \pnum \effects @@ -2650,7 +2345,7 @@ \tcode{insert(p - begin(), basic_string(first, last, get_allocator()))}. \pnum -\returns An iterator which refers to the copy of the first inserted character, or +\returns An iterator which refers to the first inserted character, or \tcode{p} if \tcode{first == last}. \end{itemdescr} @@ -2661,11 +2356,7 @@ \begin{itemdescr} \pnum -\effects As if by \tcode{insert(p, il.begin(), il.end())}. - -\pnum -\returns An iterator which refers to the copy of the first inserted character, or -\tcode{p} if \tcode{i1} is empty. +\effects Equivalent to: \tcode{return insert(p, il.begin(), il.end());} \end{itemdescr} \rSec4[string.erase]{\tcode{basic_string::erase}} @@ -2687,18 +2378,7 @@ Determines the effective length \tcode{xlen} of the string to be removed as the smaller of \tcode{n} and \tcode{size() - pos}. - -\pnum -The function then replaces the string controlled by -\tcode{*this} -with a string of length -\tcode{size() - xlen} -whose first \tcode{pos} elements are a copy of the initial elements of the original string controlled by -\tcode{*this}, -and whose remaining elements are a copy of the elements of the original string controlled by -\tcode{*this} -beginning at position -\tcode{pos + xlen}. +Removes the characters in the range \range{begin() + pos}{begin() + pos + xlen}. \pnum \returns @@ -2711,6 +2391,10 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\expects +\tcode{p} is a valid dereferenceable iterator on \tcode{*this}. + \pnum \throws Nothing. @@ -2734,11 +2418,9 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{first} and \tcode{last} are valid iterators on -\tcode{*this}, -defining a range -\tcode{[first, last)}. +\tcode{*this}. \range{first}{last} is a valid range. \pnum \throws Nothing. @@ -2764,7 +2446,7 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{!empty()}. \pnum @@ -2772,7 +2454,7 @@ \pnum \effects -Equivalent to \tcode{erase(size() - 1, 1)}. +Equivalent to \tcode{erase(end() - 1)}. \end{itemdescr} \rSec4[string.replace]{\tcode{basic_string::replace}} @@ -2794,23 +2476,12 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\throws -\tcode{out_of_range} -if -\tcode{pos1 > size()} -or -\tcode{pos2 > str.size()}. - \pnum \effects -Determines the effective length \tcode{rlen} of the string to be inserted -as the smaller of \tcode{n2} and \tcode{str.size() - pos2} and calls -\tcode{replace(pos1, n1, str.data() + pos2, rlen)}. - -\pnum -\returns -\tcode{*this}. +Equivalent to: +\begin{codeblock} +return replace(pos1, n1, basic_string_view(str).substr(pos2, n2)); +\end{codeblock} \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -2820,21 +2491,24 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} + \pnum \effects Equivalent to: \begin{codeblock} -{ - basic_string_view sv = t; - return replace(pos1, n1, sv.data(), sv.size()); -} +basic_string_view sv = t; +return replace(pos1, n1, sv.data(), sv.size()); \end{codeblock} - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -2846,29 +2520,23 @@ \begin{itemdescr} \pnum -\throws -\tcode{out_of_range} -if -\tcode{pos1 > size()} -or -\tcode{pos2 > sv.size()}. +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} \pnum \effects -Creates a variable, \tcode{sv}, as if by \tcode{basic_string_view sv = t}. -Determines the effective length \tcode{rlen} of the string to be inserted -as the smaller of \tcode{n2} and \tcode{sv.size() - pos2} -and calls \tcode{replace(pos1, n1, sv.data() + pos2, rlen)}. - -\pnum -\remarks -This function shall not participate in overload resolution -unless \tcode{is_convertible_v>} -is \tcode{true} and \tcode{is_convertible_v} is \tcode{false}. - -\pnum -\returns -\tcode{*this}. +Equivalent to: +\begin{codeblock} +basic_string_view sv = t; +return replace(pos1, n1, sv.substr(pos2, n2)); +\end{codeblock} \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -2878,24 +2546,24 @@ \begin{itemdescr} \pnum -\requires \tcode{s} points to an array of at -least \tcode{n2} elements of \tcode{charT}. +\expects \range{s}{s + n2} is a valid range. \pnum -\throws \tcode{out_of_range} if \tcode{pos1 > size()} or \tcode{length_error} -if the length of the resulting string would exceed \tcode{max_size()} (see below). +\throws +\begin{itemize} +\item \tcode{out_of_range} if \tcode{pos1 > size()}, +\item \tcode{length_error} if the length of the resulting string +would exceed \tcode{max_size()} (see below), or +\item any exceptions thrown by \tcode{allocator_traits::allocate}. +\end{itemize} \pnum \effects Determines the effective length \tcode{xlen} of the string to be removed as the smaller of \tcode{n1} and \tcode{size() - pos1}. If \tcode{size() - xlen >= max_size() - n2} throws \tcode{length_error}. Otherwise, -the function replaces the string controlled by *\tcode{this} with a string of -length \tcode{size() - xlen + n2} whose first \tcode{pos1} elements are a copy -of the initial elements of the original string controlled by \tcode{*this}, -whose next \tcode{n2} elements are a copy of the initial \tcode{n2} elements -of \tcode{s}, and whose remaining elements are a copy of the elements of the -original string controlled by \tcode{*this} beginning at position -\tcode{pos + xlen}. +the function replaces the characters in the range +\range{begin() + pos1}{begin() + pos1 + xlen} +with a copy of the range \range{s}{s + n2}. \pnum \returns @@ -2908,10 +2576,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\requires \tcode{s} points to an array of at least -\tcode{traits::length(s) + 1} elements of \tcode{charT}. - \pnum \effects Equivalent to: \tcode{return replace(pos, n, s, traits::length(s));} \end{itemdescr} @@ -2923,7 +2587,24 @@ \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return replace(pos1, n1, basic_string(n2, c));} +\throws +\begin{itemize} +\item \tcode{out_of_range} if \tcode{pos1 > size()}, +\item \tcode{length_error} if the length of the resulting string +would exceed \tcode{max_size()} (see below), or +\item any exceptions thrown by \tcode{allocator_traits::allocate.} +\end{itemize} + +\pnum +\effects Determines the effective length \tcode{xlen} of the string to be +removed as the smaller of \tcode{n1} and \tcode{size() - pos1}. If +\tcode{size() - xlen >=} \tcode{max_size() - n2} throws \tcode{length_error}. Otherwise, +the function replaces the characters in the range +\range{begin() + pos1}{begin() + pos1 + xlen} +with \tcode{n2} copies of \tcode{c}. + +\pnum +\returns \tcode{*this}. \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -2932,17 +2613,9 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\requires -\range{begin()}{i1} and \range{i1}{i2} are valid ranges. - \pnum \effects -Calls \tcode{replace(i1 - begin(), i2 - i1, str)}. - -\pnum -\returns -\tcode{*this}. +Equivalent to: \tcode{return replace(i1, i2, basic_string_view(str));} \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -2953,25 +2626,28 @@ \begin{itemdescr} \pnum -\requires +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} + +\pnum +\expects \range{begin()}{i1} and \range{i1}{i2} are valid ranges. \pnum \effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and then -calls \tcode{replace(i1 - begin(), i2 - i1, sv)}. - -\pnum -\returns -\tcode{*this}. - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. -\end{itemdescr} +Equivalent to: +\begin{codeblock} +basic_string_view sv = t; +return replace(i1 - begin(), i2 - i1, sv.data(), sv.size()); +\end{codeblock} +\end{itemdescr} \indexlibrarymember{replace}{basic_string}% \begin{itemdecl} @@ -2980,15 +2656,8 @@ \begin{itemdescr} \pnum -\requires \range{begin()}{i1} and \range{i1}{i2} are valid ranges and -\tcode{s} points to an array of at least \tcode{n} elements of \tcode{charT}. - -\pnum -\effects Calls \tcode{replace(i1 - begin(), i2 - i1, s, n)}. - -\pnum -\returns -\tcode{*this}. +\effects +Equivalent to: \tcode{return replace(i1, i2, basic_string_view(s, n));} \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -2998,16 +2667,8 @@ \begin{itemdescr} \pnum -\requires \range{begin()}{i1} and \range{i1}{i2} are valid ranges and -\tcode{s} points to an array of at least \tcode{traits::\brk{}length(s) + 1} -elements of \tcode{charT}. - -\pnum -\effects Calls \tcode{replace(i1 - begin(), i2 - i1, s, traits::length(s))}. - -\pnum -\returns -\tcode{*this}. +\effects +Equivalent to: \tcode{return replace(i1, i2, basic_string_view(s));} \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -3017,14 +2678,11 @@ \begin{itemdescr} \pnum -\requires \range{begin()}{i1} and \range{i1}{i2} are valid ranges. +\expects \range{begin()}{i1} and \range{i1}{i2} are valid ranges. \pnum -\effects Calls \tcode{replace(i1 - begin(), i2 - i1, basic_string(n, c))}. - -\pnum -\returns -\tcode{*this}. +\effects +Equivalent to: \tcode{return replace(i1 - begin(), i2 - i1, n, c);} \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -3035,14 +2693,13 @@ \begin{itemdescr} \pnum -\requires \range{begin()}{i1}, \range{i1}{i2} and \range{j1}{j2} are valid ranges. - -\pnum -\effects Calls \tcode{replace(i1 - begin(), i2 - i1, basic_string(j1, j2, get_allocator()))}. +\constraints +\tcode{InputIterator} is a type that qualifies as an input +iterator\iref{container.requirements.general}. \pnum -\returns -\tcode{*this}. +\effects +Equivalent to: \tcode{return replace(i1, i2, basic_string(j1, j2, get_allocator()));} \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -3052,17 +2709,10 @@ \begin{itemdescr} \pnum -\requires \range{begin()}{i1} and \range{i1}{i2} are valid ranges. - -\pnum -\effects Calls \tcode{replace(i1 - begin(), i2 - i1, il.begin(), il.size())}. - -\pnum -\returns -\tcode{*this}. +\effects +Equivalent to: \tcode{return replace(i1, i2, il.begin(), il.size());} \end{itemdescr} - \rSec4[string.copy]{\tcode{basic_string::copy}} \indexlibrarymember{copy}{basic_string}% @@ -3071,27 +2721,11 @@ \end{itemdecl} \begin{itemdescr} -\pnum -Let \tcode{rlen} be the smaller of \tcode{n} and \tcode{size() - pos}. - -\pnum -\throws -\tcode{out_of_range} -if -\tcode{pos > size()}. - -\pnum -\requires -\range{s}{s + rlen} is a valid range. - \pnum \effects -Equivalent to \tcode{traits::copy(s, data() + pos, rlen)}. +Equivalent to: +\tcode{return basic_string_view(*this).copy(s, n, pos);} \begin{note} This does not terminate \tcode{s} with a null object. \end{note} - -\pnum -\returns -\tcode{rlen}. \end{itemdescr} \rSec4[string.swap]{\tcode{basic_string::swap}} @@ -3104,6 +2738,12 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\expects +\tcode{allocator_traits::propagate_on_container_swap::value} is \tcode{true} +or +\tcode{get_allocator() == s.get_allocator()}. + \pnum \ensures \tcode{*this} @@ -3138,8 +2778,8 @@ \complexity Constant time. \pnum -\requires -The program shall not alter any of the values stored in the character array. +\remarks +The program shall not modify any of the values stored in the character array; otherwise, the behavior is undefined. \end{itemdescr} \indexlibrarymember{data}{basic_string}% @@ -3156,8 +2796,9 @@ \complexity Constant time. \pnum -\requires -The program shall not alter the value stored at \tcode{p + size()}. +\remarks +The program shall not modify the value stored at \tcode{p + size()} +to any value other than \tcode{charT()}; otherwise, the behavior is undefined. \end{itemdescr} \indexlibrarymember{operator basic_string_view}{basic_string}% @@ -3185,556 +2826,95 @@ copy of the most recent replacement. \end{itemdescr} -\rSec4[string.find]{\tcode{basic_string::find}} - -\indexlibrarymember{find}{basic_string}% -\begin{itemdecl} -template - size_type find(const T& t, size_type pos = 0) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and then -determines the lowest position \tcode{xpos}, if possible, such that both of -the following conditions hold: -\begin{itemize} -\item -\tcode{pos <= xpos} and -\tcode{xpos + sv.size() <= size()}; -\item -\indexlibrary{\idxcode{eq}!\idxcode{char_traits}}% -\tcode{traits::eq(at(xpos + I), sv.at(I))} -for all elements \tcode{I} of the data referenced by \tcode{sv}. -\end{itemize} - -\pnum -\returns -\tcode{xpos} if the function can determine such a value for \tcode{xpos}. -Otherwise, returns -\tcode{npos}. +\rSec4[string.find]{Searching} \pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. +Let \placeholder{F} be one of +\tcode{find}, \tcode{rfind}, \tcode{find_first_of}, \tcode{find_last_of}, +\tcode{find_first_not_of}, and \tcode{find_last_not_of}. -\pnum -\throws -Nothing unless the initialization of \tcode{sv} throws an exception. -\end{itemdescr} - -\indexlibrarymember{find}{basic_string}% -\begin{itemdecl} -size_type find(const basic_string& str, size_type pos = 0) const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Equivalent to: \tcode{return find(basic_string_view(str), pos);} -\end{itemdescr} - -\indexlibrarymember{find}{basic_string}% -\begin{itemdecl} -size_type find(const charT* s, size_type pos, size_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find(basic_string_view(s, n), pos)}. -\end{itemdescr} - -\indexlibrarymember{find}{basic_string}% -\begin{itemdecl} -size_type find(const charT* s, size_type pos = 0) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires \tcode{s} points to an array of at least \tcode{traits::length(s) + 1} -elements of \tcode{charT}. - -\pnum -\returns -\tcode{find(basic_string_view(s), pos)}. -\end{itemdescr} - -\indexlibrarymember{find}{basic_string}% -\begin{itemdecl} -size_type find(charT c, size_type pos = 0) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find(basic_string(1, c), pos)}. -\end{itemdescr} - -\rSec4[string.rfind]{\tcode{basic_string::rfind}} - -\indexlibrarymember{rfind}{basic_string}% -\begin{itemdecl} -template - size_type rfind(const T& t, size_type pos = npos) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and then -determines the highest position \tcode{xpos}, if possible, such that both of -the following conditions hold: \begin{itemize} \item -\tcode{xpos <= pos} -and -\tcode{xpos + sv.size() <= size()}; -\item -\indexlibrary{\idxcode{eq}!\idxcode{char_traits}}% -\tcode{traits::eq(at(xpos + I), sv.at(I))} -for all elements \tcode{I} of the data referenced by \tcode{sv}. -\end{itemize} - -\pnum -\returns -\tcode{xpos} if the function can determine such a value for \tcode{xpos}. -Otherwise, returns -\tcode{npos}. - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. - -\pnum -\throws -Nothing unless the initialization of \tcode{sv} throws an exception. -\end{itemdescr} - -\indexlibrarymember{rfind}{basic_string}% -\begin{itemdecl} -size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Equivalent to: \tcode{return rfind(basic_string_view(str), pos);} -\end{itemdescr} - -\indexlibrarymember{rfind}{basic_string}% -\begin{itemdecl} -size_type rfind(const charT* s, size_type pos, size_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{rfind(basic_string_view(s, n), pos)}. -\end{itemdescr} - -\indexlibrarymember{rfind}{basic_string}% -\begin{itemdecl} -size_type rfind(const charT* s, size_type pos = npos) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires \tcode{s} points to an array of at least \tcode{traits::length(s) + 1} -elements of \tcode{charT}. - -\pnum -\returns -\tcode{rfind(basic_string_view(s), pos)}. -\end{itemdescr} - -\indexlibrarymember{rfind}{basic_string}% -\begin{itemdecl} -size_type rfind(charT c, size_type pos = npos) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{rfind(basic_string(1, c), pos)}. -\end{itemdescr} - -\rSec4[string.find.first.of]{\tcode{basic_string::find_first_of}} - -\indexlibrarymember{find_first_of}{basic_string}% -\begin{itemdecl} -template - size_type find_first_of(const T& t, size_type pos = 0) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and then -determines the lowest position \tcode{xpos}, if possible, such that both of -the following conditions hold: - -\begin{itemize} -\item -\tcode{pos <= xpos} -and -\tcode{xpos < size()}; -\item -\indexlibrary{\idxcode{eq}!\idxcode{char_traits}}% -\tcode{traits::eq(at(xpos), sv.at(I))} -for some element \tcode{I} of the data referenced by \tcode{sv}. -\end{itemize} - -\pnum -\returns -\tcode{xpos} if the function can determine such a value for \tcode{xpos}. -Otherwise, returns -\tcode{npos}. - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. - -\pnum -\throws -Nothing unless the initialization of \tcode{sv} throws an exception. -\end{itemdescr} - -\indexlibrarymember{find_first_of}{basic_string}% -\begin{itemdecl} -size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Equivalent to: \tcode{return find_first_of(basic_string_view(str), pos);} -\end{itemdescr} - -\indexlibrarymember{find_first_of}{basic_string}% -\begin{itemdecl} -size_type find_first_of(const charT* s, size_type pos, size_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find_first_of(basic_string_view(s, n), pos)}. -\end{itemdescr} - -\indexlibrarymember{find_first_of}{basic_string}% -\begin{itemdecl} -size_type find_first_of(const charT* s, size_type pos = 0) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires \tcode{s} points to an array of at least \tcode{traits::length(s) + 1} -elements of \tcode{charT}. - -\pnum -\returns -\tcode{find_first_of(basic_string_view(s), pos)}. -\end{itemdescr} - -\indexlibrarymember{find_first_of}{basic_string}% -\begin{itemdecl} -size_type find_first_of(charT c, size_type pos = 0) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find_first_of(basic_string(1, c), pos)}. -\end{itemdescr} - -\rSec4[string.find.last.of]{\tcode{basic_string::find_last_of}} - -\indexlibrarymember{find_last_of}{basic_string}% -\begin{itemdecl} -template - size_type find_last_of(const T& t, size_type pos = npos) const; -\end{itemdecl} +Each member function of the form +\begin{codeblock} +size_type @\placeholder{F}@(const basic_string& str, size_type pos) const noexcept; +\end{codeblock} +has effects equivalent to: +\tcode{return \placeholder{F}(basic_string_view(str), pos);} -\begin{itemdescr} -\pnum -\effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and then -determines the highest position \tcode{xpos}, if possible, such that both of -the following conditions hold: -\begin{itemize} \item -\tcode{xpos <= pos} -and -\tcode{xpos < size()}; -\item -\indexlibrary{\idxcode{eq}!\idxcode{char_traits}}% -\tcode{traits::eq(at(xpos), sv.at(I))} -for some element \tcode{I} of the data referenced by \tcode{sv}. -\end{itemize} - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. - -\pnum -\throws -Nothing unless the initialization of \tcode{sv} throws an exception. - -\pnum -\returns -\tcode{xpos} if the function can determine such a value for \tcode{xpos}. -Otherwise, returns -\tcode{npos}. -\end{itemdescr} - -\indexlibrarymember{find_last_of}{basic_string}% -\begin{itemdecl} -size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Equivalent to: \tcode{return find_last_of(basic_string_view(str), pos);} -\end{itemdescr} - -\indexlibrarymember{find_last_of}{basic_string}% -\begin{itemdecl} -size_type find_last_of(const charT* s, size_type pos, size_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find_last_of(basic_string_view(s, n), pos)}. -\end{itemdescr} - -\indexlibrarymember{find_last_of}{basic_string}% -\begin{itemdecl} -size_type find_last_of(const charT* s, size_type pos = npos) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires \tcode{s} points to an array of at least \tcode{traits::length(s) + 1} -elements of \tcode{charT}. - -\pnum -\returns -\tcode{find_last_of(basic_string_view(s), pos)}. -\end{itemdescr} - -\indexlibrarymember{find_last_of}{basic_string}% -\begin{itemdecl} -size_type find_last_of(charT c, size_type pos = npos) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find_last_of(basic_string(1, c), pos)}. -\end{itemdescr} - -\rSec4[string.find.first.not.of]{\tcode{basic_string::find_first_not_of}} - -\indexlibrarymember{find_first_not_of}{basic_string}% -\begin{itemdecl} -template - size_type find_first_not_of(const T& t, size_type pos = 0) const; -\end{itemdecl} +Each member function of the form +\begin{codeblock} +size_type @\placeholder{F}@(const charT* s, size_type pos) const; +\end{codeblock} +has effects equivalent to: +\tcode{return \placeholder{F}(basic_string_view(s), pos);} -\begin{itemdescr} -\pnum -\effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and then -determines the lowest position \tcode{xpos}, if possible, such that both of -the following conditions hold: -\begin{itemize} \item -\tcode{pos <= xpos} -and -\tcode{xpos < size()}; -\item -\indexlibrary{\idxcode{eq}!\idxcode{char_traits}}% -\tcode{traits::eq(at(xpos), sv.at(I))} -for no element \tcode{I} of the data referenced by \tcode{sv}. -\end{itemize} - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. - -\pnum -\throws -Nothing unless the initialization of \tcode{sv} throws an exception. - -\pnum -\returns -\tcode{xpos} if the function can determine such a value for \tcode{xpos}. -Otherwise, returns -\tcode{npos}. -\end{itemdescr} - -\indexlibrarymember{find_first_not_of}{basic_string}% -\begin{itemdecl} -size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Equivalent to: +Each member function of the form \begin{codeblock} -return find_first_not_of(basic_string_view(str), pos); +size_type @\placeholder{F}@(const charT* s, size_type pos, size_type n) const; \end{codeblock} -\end{itemdescr} - -\indexlibrarymember{find_first_not_of}{basic_string}% -\begin{itemdecl} -size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find_first_not_of(basic_string_view(s, n), pos)}. -\end{itemdescr} - -\indexlibrarymember{find_first_not_of}{basic_string}% -\begin{itemdecl} -size_type find_first_not_of(const charT* s, size_type pos = 0) const; -\end{itemdecl} +has effects equivalent to: +\tcode{return \placeholder{F}(basic_string_view(s, n), pos);} -\begin{itemdescr} -\pnum -\requires \tcode{s} points to an array of at least \tcode{traits::length(s) + 1} -elements of \tcode{charT}. - -\pnum -\returns -\tcode{find_first_not_of(basic_string_view(s), pos)}. -\end{itemdescr} - -\indexlibrarymember{find_first_not_of}{basic_string}% -\begin{itemdecl} -size_type find_first_not_of(charT c, size_type pos = 0) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find_first_not_of(basic_string(1, c), pos)}. -\end{itemdescr} - -\rSec4[string.find.last.not.of]{\tcode{basic_string::find_last_not_of}} - -\indexlibrarymember{find_last_not_of}{basic_string}% -\begin{itemdecl} -template - size_type find_last_not_of(const T& t, size_type pos = npos) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and then -determines the highest position \tcode{xpos}, if possible, such that both of -the following conditions hold: -\begin{itemize} \item -\tcode{xpos <= pos} -and -\tcode{xpos < size()}; -\item -\indexlibrary{\idxcode{eq}!\idxcode{char_traits}}% -\tcode{traits::eq(at(xpos), sv.at(I))} -for no element \tcode{I} of the data referenced by \tcode{sv}. -\end{itemize} - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. - -\pnum -\throws -Nothing unless the initialization of \tcode{sv} throws an exception. - -\pnum -\returns -\tcode{xpos} if the function can determine such a value for \tcode{xpos}. -Otherwise, returns -\tcode{npos}. -\end{itemdescr} - -\indexlibrarymember{find_last_not_of}{basic_string}% -\begin{itemdecl} -size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Equivalent to: +Each member function of the form \begin{codeblock} -return find_last_not_of(basic_string_view(str), pos); +size_type @\placeholder{F}@(charT c, size_type pos) const noexcept; \end{codeblock} -\end{itemdescr} - -\indexlibrarymember{find_last_not_of}{basic_string}% -\begin{itemdecl} -size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{find_last_not_of(basic_string_view(s, n), pos)}. -\end{itemdescr} +has effects equivalent to: +\begin{codeblock} +return @\placeholder{F}@(basic_string_view(addressof(c), 1), pos); +\end{codeblock} +\end{itemize} +\indexlibrarymember{find}{basic_string}% +\indexlibrarymember{rfind}{basic_string}% +\indexlibrarymember{find_first_of}{basic_string}% +\indexlibrarymember{find_last_of}{basic_string}% +\indexlibrarymember{find_first_not_of}{basic_string}% \indexlibrarymember{find_last_not_of}{basic_string}% \begin{itemdecl} -size_type find_last_not_of(const charT* s, size_type pos = npos) const; +template + size_type find(const T& t, size_type pos = 0) const noexcept(@\seebelow@); +template + size_type rfind(const T& t, size_type pos = npos) const noexcept(@\seebelow@); +template + size_type find_first_of(const T& t, size_type pos = 0) const noexcept(@\seebelow@); +template + size_type find_last_of(const T& t, size_type pos = npos) const noexcept(@\seebelow@); +template + size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept(@\seebelow@); +template + size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept(@\seebelow@); \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{s} points to an array of at least \tcode{traits::length(s) + 1} -elements of \tcode{charT}. +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} \pnum -\returns -\tcode{find_last_not_of(basic_string_view(s), pos)}. -\end{itemdescr} - -\indexlibrarymember{find_last_not_of}{basic_string}% -\begin{itemdecl} -size_type find_last_not_of(charT c, size_type pos = npos) const; -\end{itemdecl} +\effects +Let \placeholder{G} be the name of the function. +Equivalent to: +\begin{codeblock} +basic_string_view s = *this, sv = t; +return s.@\placeholder{G}@(sv, pos); +\end{codeblock} -\begin{itemdescr} \pnum -\returns -\tcode{find_last_not_of(basic_string(1, c), pos)}. +\remarks +The expression inside \tcode{noexcept} is equivalent to +\tcode{is_nothrow_convertible_v>}. \end{itemdescr} \rSec4[string.substr]{\tcode{basic_string::substr}} @@ -3766,46 +2946,29 @@ \indexlibrarymember{compare}{basic_string}% \begin{itemdecl} template - int compare(const T& t) const; + int compare(const T& t) const noexcept(@\seebelow@); \end{itemdecl} \begin{itemdescr} \pnum -\effects -Creates a variable, \tcode{sv}, as if by -\tcode{basic_string_view sv = t;} and then -determines the effective length -\tcode{rlen} -of the strings to compare as the smaller of -\tcode{size()} -and -\tcode{sv.size()}. -The function then compares the two strings by calling -\tcode{traits::compare(data(), sv.data(), rlen)}. +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} \pnum -\returns -The nonzero result if the result of the comparison is nonzero. -Otherwise, returns a value as indicated in \tref{strings.compare}. - -\begin{floattable}{\tcode{compare()} results}{tab:strings.compare} -{lc} -\topline -\lhdr{Condition} & \rhdr{Return Value} \\ \capsep -\tcode{size() < \ sv.size()} & \tcode{< 0} \\ -\tcode{size() == sv.size()} & \tcode{ \ 0} \\ -\tcode{size() > \ sv.size()} & \tcode{> 0} \\ -\end{floattable} +\effects +Equivalent to: \tcode{return basic_string_view(*this).compare(t);} \pnum \remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. - -\pnum -\throws -Nothing unless the initialization of \tcode{sv} throws an exception. +The expression inside \tcode{noexcept} is equivalent to +\tcode{is_nothrow_convertible_v>}. \end{itemdescr} \indexlibrarymember{compare}{basic_string}% @@ -3815,21 +2978,23 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} + \pnum \effects Equivalent to: \begin{codeblock} -{ - basic_string_view sv = t; - return basic_string_view(data(), size()).substr(pos1, n1).compare(sv); -} +return basic_string_view(*this).substr(pos1, n1).compare(t); \end{codeblock} - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_convertible_v>} is \tcode{true} and -\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{compare}{basic_string}% @@ -3839,20 +3004,24 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\constraints +\begin{itemize} +\item +\tcode{is_convertible_v>} is +\tcode{true} and +\item +\tcode{is_convertible_v} is +\tcode{false}. +\end{itemize} + \pnum \effects Equivalent to: \begin{codeblock} -basic_string_view sv = t; -return basic_string_view( - data(), size()).substr(pos1, n1).compare(sv.substr(pos2, n2)); +basic_string_view s = *this, sv = t; +return s.substr(pos1, n1).compare(sv.substr(pos2, n2)); \end{codeblock} - -\pnum -\remarks -This function shall not participate in overload resolution -unless \tcode{is_convertible_v>} -is \tcode{true} and \tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{compare}{basic_string}% @@ -3900,8 +3069,8 @@ \begin{itemdescr} \pnum -\returns -\tcode{compare(basic_string(s))}. +\effects Equivalent to: +\tcode{return compare(basic_string_view(s));} \end{itemdescr} \indexlibrarymember{compare}{basic_string}% @@ -3911,7 +3080,8 @@ \begin{itemdescr} \pnum -\returns \tcode{basic_string(*this, pos, n1).compare(basic_string(s))}. +\effects +Equivalent to: \tcode{return compare(pos, n1, basic_string_view(s));} \end{itemdescr} \indexlibrarymember{compare}{basic_string}% @@ -3921,7 +3091,8 @@ \begin{itemdescr} \pnum -\returns \tcode{basic_string(*this, pos, n1).compare(basic_string(s, n2))}. +\effects +Equivalent to: \tcode{return compare(pos, n1, basic_string_view(s, n2));} \end{itemdescr} \rSec4[string.starts.with]{\tcode{basic_string::starts_with}} @@ -3977,7 +3148,7 @@ \begin{itemdescr} \pnum \returns -\tcode{basic_string(lhs).append(rhs)}. +\tcode{std::move(basic_string(lhs).append(rhs))}. \end{itemdescr} \indexlibrarymember{operator+}{basic_string}% @@ -4020,9 +3191,6 @@ \pnum \returns \tcode{std::move(lhs.append(rhs))}. -\begin{note} -Or equivalently, \tcode{std::move(rhs.insert(0, lhs))}. -\end{note} \end{itemdescr} \indexlibrarymember{operator+}{basic_string}% @@ -4149,246 +3317,63 @@ \tcode{std::move(lhs.append(1, rhs))}. \end{itemdescr} -\rSec3[string.operator==]{\tcode{operator==}} - -\indexlibrarymember{operator==}{basic_string}% +\rSec3[string.comparison]{Non-member comparison functions} \begin{itemdecl} template bool operator==(const basic_string& lhs, const basic_string& rhs) noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{lhs.compare(rhs) == 0}. -\end{itemdescr} - -\indexlibrarymember{operator==}{basic_string}% -\begin{itemdecl} template bool operator==(const charT* lhs, const basic_string& rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{rhs == lhs}. -\end{itemdescr} - -\indexlibrarymember{operator==}{basic_string}% -\begin{itemdecl} template bool operator==(const basic_string& lhs, const charT* rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires \tcode{rhs} points to an array of at least \tcode{traits::length(rhs) + 1} -elements of \tcode{charT}. - -\pnum -\returns -\tcode{lhs.compare(rhs) == 0}. -\end{itemdescr} -\rSec3[string.op!=]{\tcode{operator!=}} - -\indexlibrarymember{operator"!=}{basic_string}% -\begin{itemdecl} template bool operator!=(const basic_string& lhs, const basic_string& rhs) noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{!(lhs == rhs)}. -\end{itemdescr} - -\indexlibrarymember{operator"!=}{basic_string}% -\begin{itemdecl} template bool operator!=(const charT* lhs, const basic_string& rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{rhs != lhs}. -\end{itemdescr} - -\indexlibrarymember{operator"!=}{basic_string}% -\begin{itemdecl} template bool operator!=(const basic_string& lhs, const charT* rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires \tcode{rhs} points to an array of at least \tcode{traits::length(rhs) + 1} -elements of \tcode{charT}. - -\pnum -\returns -\tcode{lhs.compare(rhs) != 0}. -\end{itemdescr} - -\rSec3[string.op<]{\tcode{operator<}} -\indexlibrarymember{operator<}{basic_string}% -\begin{itemdecl} template - bool operator<(const basic_string& lhs, - const basic_string& rhs) noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{lhs.compare(rhs) < 0}. -\end{itemdescr} - -\indexlibrarymember{operator<}{basic_string}% -\begin{itemdecl} + bool operator< (const basic_string& lhs, + const basic_string& rhs) noexcept; template - bool operator<(const charT* lhs, const basic_string& rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{rhs.compare(lhs) > 0}. -\end{itemdescr} - -\indexlibrarymember{operator<}{basic_string}% -\begin{itemdecl} + bool operator< (const charT* lhs, const basic_string& rhs); template - bool operator<(const basic_string& lhs, const charT* rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{lhs.compare(rhs) < 0}. -\end{itemdescr} + bool operator< (const basic_string& lhs, const charT* rhs); -\rSec3[string.op>]{\tcode{operator>}} - -\indexlibrarymember{operator>}{basic_string}% -\begin{itemdecl} template - bool operator>(const basic_string& lhs, - const basic_string& rhs) noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{lhs.compare(rhs) > 0}. -\end{itemdescr} - -\indexlibrarymember{operator>}{basic_string}% -\begin{itemdecl} + bool operator> (const basic_string& lhs, + const basic_string& rhs) noexcept; template - bool operator>(const charT* lhs, const basic_string& rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{rhs.compare(lhs) < 0}. -\end{itemdescr} - -\indexlibrarymember{operator>}{basic_string}% -\begin{itemdecl} + bool operator> (const charT* lhs, const basic_string& rhs); template - bool operator>(const basic_string& lhs, const charT* rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{lhs.compare(rhs) > 0}. -\end{itemdescr} - -\rSec3[string.op<=]{\tcode{operator<=}} + bool operator> (const basic_string& lhs, const charT* rhs); -\indexlibrarymember{operator<=}{basic_string}% -\begin{itemdecl} template bool operator<=(const basic_string& lhs, const basic_string& rhs) noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{lhs.compare(rhs) <= 0}. -\end{itemdescr} - -\indexlibrarymember{operator<=}{basic_string}% -\begin{itemdecl} template bool operator<=(const charT* lhs, const basic_string& rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{rhs.compare(lhs) >= 0}. -\end{itemdescr} - -\indexlibrarymember{operator<=}{basic_string}% -\begin{itemdecl} template bool operator<=(const basic_string& lhs, const charT* rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{lhs.compare(rhs) <= 0}. -\end{itemdescr} - -\rSec3[string.op>=]{\tcode{operator>=}} -\indexlibrarymember{operator>=}{basic_string}% -\begin{itemdecl} template bool operator>=(const basic_string& lhs, const basic_string& rhs) noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{lhs.compare(rhs) >= 0}. -\end{itemdescr} - -\indexlibrarymember{operator>=}{basic_string}% -\begin{itemdecl} template bool operator>=(const charT* lhs, const basic_string& rhs); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{rhs.compare(lhs) <= 0}. -\end{itemdescr} - -\indexlibrarymember{operator>=}{basic_string}% -\begin{itemdecl} template bool operator>=(const basic_string& lhs, const charT* rhs); \end{itemdecl} - \begin{itemdescr} \pnum -\returns -\tcode{lhs.compare(rhs) >= 0}. +\effects Let \tcode{\placeholder{op}} be the operator. +Equivalent to: +\begin{codeblock} + return basic_string_view(lhs) @\placeholder{op}@ basic_string_view(rhs); +\end{codeblock} \end{itemdescr} \rSec3[string.special]{\tcode{swap}} @@ -5053,8 +4038,10 @@ \end{codeblock} \pnum -In every specialization \tcode{basic_string_view}, the type \tcode{traits} shall satisfy the character traits requirements\iref{char.traits}, -and the type \tcode{traits::char_type} shall name the same type as \tcode{charT}. +In every specialization \tcode{basic_string_view}, the type \tcode{traits} shall satisfy the character traits requirements\iref{char.traits}. +\begin{note} +The program is ill-formed if \tcode{traits::char_type} is not the same type as \tcode{charT}. +\end{note} \pnum The type \tcode{iterator} satisfies @@ -5088,17 +4075,13 @@ \begin{itemdescr} \pnum -\requires +\expects \range{str}{str + traits::length(str)} is a valid range. \pnum \effects -Constructs a \tcode{basic_string_view}, with the postconditions -in \tref{string.view.ctr.2}. -\begin{libefftabvaluenarrow}{\tcode{basic_string_view(const charT*)} effects}{tab:string.view.ctr.2} -\tcode{data_} & \tcode{str} \\ -\tcode{size_} & \tcode{traits::length(str)} \\ -\end{libefftabvaluenarrow} +Constructs a \tcode{basic_string_view}, initializing \tcode{data_} with \tcode{str} +and initializing \tcode{size_} with \tcode{traits::length(str)}. \pnum \complexity @@ -5112,16 +4095,13 @@ \begin{itemdescr} \pnum -\requires +\expects \range{str}{str + len} is a valid range. \pnum \effects -Constructs a \tcode{basic_string_view}, with the postconditions in \tref{string.view.ctr.3}. -\begin{libefftabvaluenarrow}{\tcode{basic_string_view(const charT*, size_type)} effects}{tab:string.view.ctr.3} -\tcode{data_} & \tcode{str} \\ -\tcode{size_} & \tcode{len} \\ -\end{libefftabvaluenarrow} +Constructs a \tcode{basic_string_view}, initializing \tcode{data_} with \tcode{str} +and initializing \tcode{size_} with \tcode{len}. \end{itemdescr} \rSec3[string.view.iterators]{Iterator support} @@ -5204,18 +4184,9 @@ \rSec3[string.view.capacity]{Capacity} \indexlibrarymember{size}{basic_string_view}% -\begin{itemdecl} -constexpr size_type size() const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{size_}. -\end{itemdescr} - \indexlibrarymember{length}{basic_string_view}% \begin{itemdecl} +constexpr size_type size() const noexcept; constexpr size_type length() const noexcept; \end{itemdecl} @@ -5225,6 +4196,7 @@ \tcode{size_}. \end{itemdescr} + \indexlibrarymember{max_size}{basic_string_view}% \begin{itemdecl} constexpr size_type max_size() const noexcept; @@ -5256,7 +4228,7 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{pos < size()}. \pnum @@ -5296,7 +4268,7 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{!empty()}. \pnum @@ -5315,7 +4287,7 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{!empty()}. \pnum @@ -5354,7 +4326,7 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{n <= size()}. \pnum @@ -5369,7 +4341,7 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{n <= size()}. \pnum @@ -5404,7 +4376,7 @@ \tcode{out_of_range} if \tcode{pos > size()}. \pnum -\requires +\expects \range{s}{s + rlen} is a valid range. \pnum @@ -5598,34 +4570,41 @@ \rSec3[string.view.find]{Searching} -\pnum -This subclause specifies the \tcode{basic_string_view} member functions named -\tcode{find}, \tcode{rfind}, \tcode{find_first_of}, \tcode{find_last_of}, \tcode{find_first_not_of}, and \tcode{find_last_not_of}. - \pnum Member functions in this subclause have complexity \bigoh{\tcode{size() * str.size()}} at worst, although implementations should do better. \pnum +Let \placeholder{F} be one of +\tcode{find}, +\tcode{rfind}, +\tcode{find_first_of}, +\tcode{find_last_of}, +\tcode{find_first_not_of}, +and +\tcode{find_last_not_of}. +\begin{itemize} +\item Each member function of the form \begin{codeblock} -constexpr @\placeholder{return-type}@ @\placeholder{F}@(const charT* s, size_type pos); +constexpr @\placeholder{return-type}@ @\placeholder{F}@(const charT* s, size_type pos) const; \end{codeblock} -is equivalent to \tcode{return \placeholder{F}(basic_string_view(s), pos);} +has effects equivalent to: \tcode{return \placeholder{F}(basic_string_view(s), pos);} -\pnum +\item Each member function of the form \begin{codeblock} -constexpr @\placeholder{return-type}@ @\placeholder{F}@(const charT* s, size_type pos, size_type n); +constexpr @\placeholder{return-type}@ @\placeholder{F}@(const charT* s, size_type pos, size_type n) const; \end{codeblock} -is equivalent to \tcode{return \placeholder{F}(basic_string_view(s, n), pos);} +has effects equivalent to: \tcode{return \placeholder{F}(basic_string_view(s, n), pos);} -\pnum +\item Each member function of the form \begin{codeblock} -constexpr @\placeholder{return-type}@ @\placeholder{F}@(charT c, size_type pos); +constexpr @\placeholder{return-type}@ @\placeholder{F}@(charT c, size_type pos) const noexcept; \end{codeblock} -is equivalent to \tcode{return \placeholder{F}(basic_string_view(addressof(c), 1), pos);} +has effects equivalent to: \tcode{return \placeholder{F}(basic_string_view(addressof(c), 1), pos);} +\end{itemize} \indexlibrarymember{find}{basic_string_view}% \begin{itemdecl} @@ -5811,7 +4790,6 @@ \begin{example} A sample conforming implementation for \tcode{operator==} would be: \begin{codeblock} -template using __identity = decay_t; template constexpr bool operator==(basic_string_view lhs, basic_string_view rhs) noexcept { @@ -5819,11 +4797,11 @@ } template constexpr bool operator==(basic_string_view lhs, - __identity> rhs) noexcept { + type_identity_t> rhs) noexcept { return lhs.compare(rhs) == 0; } template - constexpr bool operator==(__identity> lhs, + constexpr bool operator==(type_identity_t> lhs, basic_string_view rhs) noexcept { return lhs.compare(rhs) == 0; } diff --git a/source/xrefdelta.tex b/source/xrefdelta.tex index 5ec9dc9021..2864dfcf6b 100644 --- a/source/xrefdelta.tex +++ b/source/xrefdelta.tex @@ -170,6 +170,19 @@ \movedxref{diff.cpp17.dcl.decl}{diff.cpp17.dcl.dcl} \movedxref{diff.cpp17.special}{diff.cpp17.class} +% P1148R0 consolidated some Clause 20 subclauses. +\movedxref{string.rfind}{string.find} +\movedxref{string.find.first.of}{string.find} +\movedxref{string.find.last.of}{string.find} +\movedxref{string.find.first.not.of}{string.find} +\movedxref{string.find.last.not.of}{string.find} +\movedxref{string.operator==}{string.comparison} +\movedxref{string.op!=}{string.comparison} +\movedxref{string.op<}{string.comparison} +\movedxref{string.op>}{string.comparison} +\movedxref{string.op<=}{string.comparison} +\movedxref{string.op>=}{string.comparison} + % Deprecated features. %\deprxref{old.label} (if moved to depr.old.label, otherwise use \movedxref) From d9521a91ab07548e888bd5be386822c0148a111f Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 25 Nov 2018 18:44:37 -0800 Subject: [PATCH 2/2] [iostream.forward.overview] Convert incomplete wording with no normative effect to an example. --- source/iostreams.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/iostreams.tex b/source/iostreams.tex index 7322117919..9059cdef88 100644 --- a/source/iostreams.tex +++ b/source/iostreams.tex @@ -366,8 +366,7 @@ \tcode{fpos} are used for specifying file position information. - -\pnum +\begin{example} The types \tcode{streampos} and @@ -377,6 +376,7 @@ and \tcode{wchar_t} respectively. +\end{example} \pnum \begin{note}