[gcc r12-2958] libstdc++: Only define basic_string::contains for C++23

Jonathan Wakely redi@gcc.gnu.org
Tue Aug 17 13:23:59 GMT 2021


https://gcc.gnu.org/g:3b3f2f7c265ef9f176cb811a8049b24538d954d9

commit r12-2958-g3b3f2f7c265ef9f176cb811a8049b24538d954d9
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Aug 16 20:42:54 2021 +0100

    libstdc++: Only define basic_string::contains for C++23
    
    The new contains member of the COW string is defined for non-strict
    gnu++20 mode as well as for C++23 modes. I think that was left in the
    committed patch unintentionally. It is inconsistent with the SSO string,
    and doesn't actually compile because it uses the
    basic_string_view::contains member which only defined for C++23.
    
    This makes it only defined for C++23.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/cow_string.h (basic_string::contains): Do not
            define for -std=gnu++20.

Diff:
---
 libstdc++-v3/include/bits/cow_string.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h
index 5b09cc2a896..61edaa85484 100644
--- a/libstdc++-v3/include/bits/cow_string.h
+++ b/libstdc++-v3/include/bits/cow_string.h
@@ -2963,8 +2963,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return __sv_type(this->data(), this->size()).ends_with(__x); }
 #endif // C++20
 
-#if __cplusplus >= 202011L \
-  || (__cplusplus == 202002L && !defined __STRICT_ANSI__)
+#if __cplusplus > 202011L
       bool
       contains(basic_string_view<_CharT, _Traits> __x) const noexcept
       { return __sv_type(this->data(), this->size()).contains(__x); }


More information about the Libstdc++-cvs mailing list