On Sun, 13 Oct 2024 at 18:59, Giuseppe D'Angelo
<giuseppe.dang...@kdab.com> wrote:
>
> Hello,
>
> On 09/10/2024 22:39, Patrick Palka wrote:
> >> +#if __glibcxx_string_view >= 202403L
> >> +  // const string & + string_view
> >> +  template<typename _CharT, typename _Traits, typename _Alloc>
> >> +    [[nodiscard]]
> >> +    constexpr inline basic_string<_CharT, _Traits, _Alloc>
> >
> > Redundant 'inline's
> >
> >> +    operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
> >> +           type_identity_t<basic_string_view<_CharT, _Traits>> __rhs)
> >> +    {
> >> +      typedef basic_string<_CharT, _Traits, _Alloc> _Str;
> >
> > These typedefs might as well be usings instead
> >
> > Besides that LGTM!
>
> Thank you for the review, updated patch attached to fix both of these.
> (Just for the record, these had been C&P from the corresponding
> operator+ overloads that deal with const char *.)

Those are from C++98 though, so the 'constexpr' is conditional and so
the 'inline' is not redundant.

I'm going to push your patch in the morning, with one tiny fix for the
COW std::string (which isn't usable in constexpr). See attached.

Thanks for implementing this.
commit 97a03ae904150a65dd2cf41816fed94c283e21b1
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Thu Oct 24 20:12:08 2024

    libstdc++: Disable parts of new test that depend on constexpr std::string
    
    The compile-time assertions don't work with -D_GLIBCXX_USE_CXX11_ABI=0.
    
    libstdc++-v3/ChangeLog:
    
            * 
testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc:
            Check __cpp_lib_constexpr_string.

diff --git 
a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc
 
b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc
index 364d5bd5aba..2d474519f60 100644
--- 
a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc
+++ 
b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc
@@ -44,6 +44,7 @@ struct convertible_to_lots
   constexpr operator std::string() const { return "convertible_to_lots3"; }
 };
 
+#if __cpp_lib_constexpr_string >= 201907 // constexpr std::string
 using namespace std::literals;
 static_assert( "costa "s + "marbella"sv == "costa marbella"s );
 static_assert( "costa "sv + "marbella"s == "costa marbella"s );
@@ -52,6 +53,7 @@ static_assert( "costa "s + convertible_to_string_view2{} == 
"costa convertible_t
 static_assert( "costa "s + convertible_to_string_view3{} == "costa 
convertible_to_sv3 non_const"s );
 static_assert( "costa "s + convertible_to_string_view_and_char_star{} == 
"costa convertible_to_sv_and_charstar1"s );
 static_assert( "costa "s + convertible_to_lots{} == "costa 
convertible_to_lots1"s );
+#endif // __cpp_lib_constexpr_string
 
 void
 test01()

Reply via email to