Skip to content

LWG Poll 4: P1679R3 string contains function #4373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions source/strings.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,10 @@
constexpr bool ends_with(basic_string_view<charT, traits> x) const noexcept;
constexpr bool ends_with(charT x) const noexcept;
constexpr bool ends_with(const charT* x) const;

constexpr bool contains(basic_string_view<charT, traits> x) const noexcept;
constexpr bool contains(charT x) const noexcept;
constexpr bool contains(const charT* x) const;
};

template<class InputIterator,
Expand Down Expand Up @@ -3222,6 +3226,24 @@
\end{codeblock}
\end{itemdescr}

\rSec4[string.contains]{\tcode{basic_string::contains}}

\indexlibrarymember{contains}{basic_string}%
\begin{itemdecl}
constexpr bool contains(basic_string_view<charT, traits> x) const noexcept;
constexpr bool contains(charT x) const noexcept;
constexpr bool contains(const charT* x) const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to:
\begin{codeblock}
return basic_string_view<charT, traits>(data(), size()).contains(x);
\end{codeblock}
\end{itemdescr}

\rSec2[string.nonmembers]{Non-member functions}

\indexlibraryglobal{basic_string}
Expand Down Expand Up @@ -4117,6 +4139,10 @@
constexpr bool ends_with(charT x) const noexcept;
constexpr bool ends_with(const charT* x) const;

constexpr bool contains(basic_string_view x) const noexcept;
constexpr bool contains(charT x) const noexcept;
constexpr bool contains(const charT* x) const;

// \ref{string.view.find}, searching
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
Expand Down Expand Up @@ -4717,6 +4743,19 @@
Equivalent to: \tcode{return ends_with(basic_string_view(x));}
\end{itemdescr}

\indexlibrarymember{contains}{basic_string_view}%
\begin{itemdecl}
constexpr bool contains(basic_string_view x) const noexcept;
constexpr bool contains(charT x) const noexcept;
constexpr bool contains(const charT* x) const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to: \tcode{return find(x) != npos;}
\end{itemdescr}

\rSec3[string.view.find]{Searching}

\pnum
Expand Down
1 change: 1 addition & 0 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@
#define @\defnlibxname{cpp_lib_span}@ 202002L // also in \libheader{span}
#define @\defnlibxname{cpp_lib_ssize}@ 201902L // also in \libheader{iterator}
#define @\defnlibxname{cpp_lib_starts_ends_with}@ 201711L // also in \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_string_contains}@ 202011L // also in \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_string_udls}@ 201304L // also in \libheader{string}
#define @\defnlibxname{cpp_lib_string_view}@ 201803L // also in \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_syncbuf}@ 201803L // also in \libheader{syncstream}
Expand Down