Skip to content

Commit 2af5da8

Browse files
authored
Merge 2024-03 LWG Motion 11
P2591R5 Concatenation of strings and string views
2 parents 2bb990d + afe922d commit 2af5da8

File tree

2 files changed

+96
-1
lines changed

2 files changed

+96
-1
lines changed

source/strings.tex

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,22 @@
18361836
constexpr basic_string<charT, traits, Allocator>
18371837
operator+(basic_string<charT, traits, Allocator>&& lhs,
18381838
charT rhs);
1839+
template<class charT, class traits, class Allocator>
1840+
constexpr basic_string<charT, traits, Allocator>
1841+
operator+(const basic_string<charT, traits, Allocator>& lhs,
1842+
type_identity_t<basic_string_view<charT, traits>> rhs);
1843+
template<class charT, class traits, class Allocator>
1844+
constexpr basic_string<charT, traits, Allocator>
1845+
operator+(basic_string<charT, traits, Allocator>&& lhs,
1846+
type_identity_t<basic_string_view<charT, traits>> rhs);
1847+
template<class charT, class traits, class Allocator>
1848+
constexpr basic_string<charT, traits, Allocator>
1849+
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
1850+
const basic_string<charT, traits, Allocator>& rhs);
1851+
template<class charT, class traits, class Allocator>
1852+
constexpr basic_string<charT, traits, Allocator>
1853+
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
1854+
basic_string<charT, traits, Allocator>&& rhs);
18391855

18401856
template<class charT, class traits, class Allocator>
18411857
constexpr bool
@@ -4851,6 +4867,85 @@
48514867
\end{codeblock}
48524868
\end{itemdescr}
48534869

4870+
\indexlibrarymember{operator+}{basic_string}%
4871+
\begin{itemdecl}
4872+
template<class charT, class traits, class Allocator>
4873+
constexpr basic_string<charT, traits, Allocator>
4874+
operator+(const basic_string<charT, traits, Allocator>& lhs,
4875+
type_identity_t<basic_string_view<charT, traits>> rhs);
4876+
\end{itemdecl}
4877+
4878+
\begin{itemdescr}
4879+
\pnum
4880+
Equivalent to:
4881+
\begin{codeblock}
4882+
basic_string<charT, traits, Allocator> r = lhs;
4883+
r.append(rhs);
4884+
return r;
4885+
\end{codeblock}
4886+
\end{itemdescr}
4887+
4888+
\indexlibrarymember{operator+}{basic_string}%
4889+
\begin{itemdecl}
4890+
template<class charT, class traits, class Allocator>
4891+
constexpr basic_string<charT, traits, Allocator>
4892+
operator+(basic_string<charT, traits, Allocator>&& lhs,
4893+
type_identity_t<basic_string_view<charT, traits>> rhs);
4894+
\end{itemdecl}
4895+
4896+
\begin{itemdescr}
4897+
\pnum
4898+
Equivalent to:
4899+
\begin{codeblock}
4900+
lhs.append(rhs);
4901+
return std::move(lhs);
4902+
\end{codeblock}
4903+
\end{itemdescr}
4904+
4905+
\indexlibrarymember{operator+}{basic_string}%
4906+
\begin{itemdecl}
4907+
template<class charT, class traits, class Allocator>
4908+
constexpr basic_string<charT, traits, Allocator>
4909+
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
4910+
const basic_string<charT, traits, Allocator>& rhs);
4911+
\end{itemdecl}
4912+
4913+
\begin{itemdescr}
4914+
\pnum
4915+
Equivalent to:
4916+
\begin{codeblock}
4917+
basic_string<charT, traits, Allocator> r = rhs;
4918+
r.insert(0, lhs);
4919+
return r;
4920+
\end{codeblock}
4921+
\end{itemdescr}
4922+
4923+
\indexlibrarymember{operator+}{basic_string}%
4924+
\begin{itemdecl}
4925+
template<class charT, class traits, class Allocator>
4926+
constexpr basic_string<charT, traits, Allocator>
4927+
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
4928+
basic_string<charT, traits, Allocator>&& rhs);
4929+
\end{itemdecl}
4930+
4931+
\begin{itemdescr}
4932+
\pnum
4933+
Equivalent to:
4934+
\begin{codeblock}
4935+
rhs.insert(0, lhs);
4936+
return std::move(rhs);
4937+
\end{codeblock}
4938+
\end{itemdescr}
4939+
4940+
\pnum
4941+
\begin{note}
4942+
Using a specialization of \tcode{type_identity_t} as a parameter type ensures
4943+
that an object of type \tcode{basic_string<charT, traits, Allocator>}
4944+
can be concatenated with an object of a type \tcode{T}
4945+
having an implicit conversion to
4946+
\tcode{basic_string_view<charT, traits>}\iref{over.match.oper}.
4947+
\end{note}
4948+
48544949
\rSec3[string.cmp]{Non-member comparison operator functions}
48554950
\begin{itemdecl}
48564951
template<class charT, class traits, class Allocator>

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@
779779
#define @\defnlibxname{cpp_lib_string_contains}@ 202011L // also in \libheader{string}, \libheader{string_view}
780780
#define @\defnlibxname{cpp_lib_string_resize_and_overwrite}@ 202110L // also in \libheader{string}
781781
#define @\defnlibxname{cpp_lib_string_udls}@ 201304L // also in \libheader{string}
782-
#define @\defnlibxname{cpp_lib_string_view}@ 201803L // also in \libheader{string}, \libheader{string_view}
782+
#define @\defnlibxname{cpp_lib_string_view}@ 202403L // also in \libheader{string}, \libheader{string_view}
783783
#define @\defnlibxname{cpp_lib_submdspan}@ 202306L // also in \libheader{mdspan}
784784
#define @\defnlibxname{cpp_lib_syncbuf}@ 201803L // also in \libheader{syncstream}
785785
#define @\defnlibxname{cpp_lib_text_encoding}@ 202306L // also in \libheader{text_encoding}

0 commit comments

Comments
 (0)