Skip to content

Commit f2b5682

Browse files
committed
Merge 2017-11 LWG Motion 18
2 parents e2d2f54 + 709bc66 commit f2b5682

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

source/strings.tex

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,13 @@
11091109
int compare(const charT* s) const;
11101110
int compare(size_type pos1, size_type n1, const charT* s) const;
11111111
int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const;
1112+
1113+
bool starts_with(basic_string_view<charT, traits> x) const noexcept;
1114+
bool starts_with(charT x) const noexcept;
1115+
bool starts_with(const charT* x) const;
1116+
bool ends_with(basic_string_view<charT, traits> x) const noexcept;
1117+
bool ends_with(charT x) const noexcept;
1118+
bool ends_with(const charT* x) const;
11121119
};
11131120

11141121
template<class InputIterator,
@@ -3677,6 +3684,42 @@
36773684
\returns \tcode{basic_string(*this, pos, n1).compare(basic_string(s, n2))}.
36783685
\end{itemdescr}
36793686

3687+
\rSec4[string.starts.with]{\tcode{basic_string::starts_with}}
3688+
3689+
\indexlibrarymember{starts_with}{basic_string}%
3690+
\begin{itemdecl}
3691+
bool starts_with(basic_string_view<charT, traits> x) const noexcept;
3692+
bool starts_with(charT x) const noexcept;
3693+
bool starts_with(const charT* x) const;
3694+
\end{itemdecl}
3695+
3696+
\begin{itemdescr}
3697+
\pnum
3698+
\effects
3699+
Equivalent to:
3700+
\begin{codeblock}
3701+
return basic_string_view<charT, traits>(data(), size()).starts_with(x);
3702+
\end{codeblock}
3703+
\end{itemdescr}
3704+
3705+
\rSec4[string.ends.with]{\tcode{basic_string::ends_with}}
3706+
3707+
\indexlibrarymember{ends_with}{basic_string}%
3708+
\begin{itemdecl}
3709+
bool ends_with(basic_string_view<charT, traits> x) const noexcept;
3710+
bool ends_with(charT x) const noexcept;
3711+
bool ends_with(const charT* x) const;
3712+
\end{itemdecl}
3713+
3714+
\begin{itemdescr}
3715+
\pnum
3716+
\effects
3717+
Equivalent to:
3718+
\begin{codeblock}
3719+
return basic_string_view<charT, traits>(data(), size()).ends_with(x);
3720+
\end{codeblock}
3721+
\end{itemdescr}
3722+
36803723
\rSec2[string.nonmembers]{\tcode{basic_string} non-member functions}
36813724

36823725
\indexlibrary{\idxcode{basic_string}}
@@ -4703,6 +4746,13 @@
47034746
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
47044747
constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const;
47054748

4749+
constexpr bool starts_with(basic_string_view x) const noexcept;
4750+
constexpr bool starts_with(charT x) const noexcept;
4751+
constexpr bool starts_with(const charT* x) const;
4752+
constexpr bool ends_with(basic_string_view x) const noexcept;
4753+
constexpr bool ends_with(charT x) const noexcept;
4754+
constexpr bool ends_with(const charT* x) const;
4755+
47064756
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
47074757
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
47084758
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
@@ -5205,6 +5255,75 @@
52055255
Equivalent to: \tcode{return substr(pos1, n1).compare(basic_string_view(s, n2));}
52065256
\end{itemdescr}
52075257

5258+
\indexlibrarymember{starts_with}{basic_string_view}%
5259+
\begin{itemdecl}
5260+
constexpr bool starts_with(basic_string_view x) const noexcept;
5261+
\end{itemdecl}
5262+
5263+
\begin{itemdescr}
5264+
\pnum
5265+
\effects
5266+
Equivalent to: \tcode{return compare(0, npos, x) == 0;}
5267+
\end{itemdescr}
5268+
5269+
\indexlibrarymember{starts_with}{basic_string_view}%
5270+
\begin{itemdecl}
5271+
constexpr bool starts_with(charT x) const noexcept;
5272+
\end{itemdecl}
5273+
5274+
\begin{itemdescr}
5275+
\pnum
5276+
\effects
5277+
Equivalent to: \tcode{return starts_with(basic_string_view(\&x, 1));}
5278+
\end{itemdescr}
5279+
5280+
\indexlibrarymember{starts_with}{basic_string_view}%
5281+
\begin{itemdecl}
5282+
constexpr bool starts_with(const charT* x) const;
5283+
\end{itemdecl}
5284+
5285+
\begin{itemdescr}
5286+
\pnum
5287+
\effects
5288+
Equivalent to: \tcode{return starts_with(basic_string_view(x));}
5289+
\end{itemdescr}
5290+
5291+
\indexlibrarymember{ends_with}{basic_string_view}%
5292+
\begin{itemdecl}
5293+
constexpr bool ends_with(basic_string_view x) const noexcept;
5294+
\end{itemdecl}
5295+
5296+
\begin{itemdescr}
5297+
\pnum
5298+
\effects
5299+
Equivalent to:
5300+
\begin{codeblock}
5301+
return size() >= x.size() && compare(size() - x.size(), npos, x) == 0;
5302+
\end{codeblock}
5303+
\end{itemdescr}
5304+
5305+
\indexlibrarymember{ends_with}{basic_string_view}%
5306+
\begin{itemdecl}
5307+
constexpr bool ends_with(charT x) const noexcept;
5308+
\end{itemdecl}
5309+
5310+
\begin{itemdescr}
5311+
\pnum
5312+
\effects
5313+
Equivalent to: \tcode{return ends_with(basic_string_view(\&x, 1));}
5314+
\end{itemdescr}
5315+
5316+
\indexlibrarymember{ends_with}{basic_string_view}%
5317+
\begin{itemdecl}
5318+
constexpr bool ends_with(const charT* x) const;
5319+
\end{itemdecl}
5320+
5321+
\begin{itemdescr}
5322+
\pnum
5323+
\effects
5324+
Equivalent to: \tcode{return ends_with(basic_string_view(x));}
5325+
\end{itemdescr}
5326+
52085327
\rSec3[string.view.find]{Searching}
52095328

52105329
\pnum

0 commit comments

Comments
 (0)