[PATCH v2] libstdc++: implement concatenation of strings and string_views
Jonathan Wakely
jwakely@redhat.com
Tue Jul 30 22:19:29 GMT 2024
On Tue, 30 Jul 2024 at 22:54, Giuseppe D'Angelo
<giuseppe.dangelo@kdab.com> wrote:
>
> On 30/07/2024 15:27, Jonathan Wakely wrote:
> > On Tue, 30 Jul 2024 at 14:08, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> >>
> >> On Tue, 30 Jul 2024 at 08:31, Giuseppe D'Angelo
> >> <giuseppe.dangelo@kdab.com> wrote:
> >>>
> >>> Hello!
> >>>
> >>> The attached patch implements adds support for P2591R5 in libstdc++
> >>> (concatenation of strings and string_views, approved in Tokyo for C++26).
> >>
> >> Thanks for this patch as well. This was on my TODO list so I'll be
> >> happy to not have to do it myself now!
>
> Thank you for the thorough review and guidance; I hope I have fixed
> everything, attaching the new patch.
Great, thanks for the quick turnaround.
One more thing that I missed last time, sorry:
+#if __glibcxx_string_view >= 202403L
+ // const string & + string_view
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
+ inline basic_string<_CharT, _Traits, _Alloc>
+ operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
+ __type_identity_t<basic_string_view<_CharT, _Traits>> __rhs)
Since this is a C++26 feature, we can use [[nodiscard]] and constexpr
unconditionally, so it can be simply:
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ [[nodiscard]]
+ constexpr basic_string<_CharT, _Traits, _Alloc>
i.e. use [[nodiscard]] not the NODISCARD macro, and constexpr instead
of the CONSTEXPR macro and the inline keyword.
But I can make those change before committing.
This patch also reminds me that we need to make the changes to replace
__type_element_t with type_element_t, as per your LWG issue to clean
that up.
>
> I don't have committing rights, so feel free to grab the patch and apply
> it at your convenience :)
>
> Thanks,
> --
> Giuseppe D'Angelo
>
More information about the Libstdc++
mailing list