On 27/01/21 12:40 +0000, Jonathan Wakely wrote:
On 15/01/21 01:23 +0000, Paul Fee via Libstdc++ wrote:
Add contains member function to basic_string_view and basic_string.
The new method is enabled for -std=gnu++20, gnu++2b and c++2b. This allows
users to access the method as a GNU extension to C++20. The conditional
test may be reduced to "__cplusplus > 202011L" once GCC has a c++2b switch.
Changes since v1 (13th Jan 2021)
* New:
Test __cplusplus >= 202011L, rather than __cplusplus > 202011L.
* As suggested by Jonathan Wakely:
Adjust formatting.
Test feature-test macro is defined by <string_view> and <version>.
Correct copyright dates on new files.
Fix comment typo.
libstdc++-v3/
Add contains member function to basic_string_view.
Likewise to basic_string_view, both with and without _GLIBCXX_USE_CXX11_ABI.
Enabled with -std=gnu++20, gnu++2b and c++2b.
* include/bits/basic_string.h (basic_string::contains): New.
* libstdc++-v3/include/std/string_view (basic_string_view::contains): New.
* testsuite/21_strings/basic_string/operations/contains/char/1.cc: New test.
* testsuite/21_strings/basic_string/operations/contains/wchar_t/1.cc:
New test.
* testsuite/21_strings/basic_string_view/operations/contains/char/1.cc:
New test.
* testsuite/21_strings/basic_string_view/operations/contains/wchar_t/1.cc:
New test.
I've committed this to master now.
Now that -std=gnu++23 is supported I changed the preprocessor
condition to just check __cplusplus > 201102L (and not enable it for
-std=gnu++20) and changed the tests to use 23 not 2b. I've attached
what I committed.
Thanks for your patch!
And here's the patch for the release notes, pushed to wwwdocs.
commit 12bb55fed649ece4d29536438cdd9853bbd85b1d
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Wed Jan 27 12:42:58 2021 +0000
Document C++23 std::string::contains support
diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
index 9d2e4f29..9b86e6c8 100644
--- a/htdocs/gcc-11/changes.html
+++ b/htdocs/gcc-11/changes.html
@@ -310,7 +310,7 @@ a work-in-progress.</p>
<li><code>std::from_chars</code> for floating-point types.</li>
</ul>
</li>
- <li>Improved experimental C++2a support, including:
+ <li>Improved experimental C++20 support, including:
<ul>
<li>Calendar additions to <code><chrono></code>.</li>
<li><code>std::bit_cast</code></li>
@@ -322,6 +322,13 @@ a work-in-progress.</p>
<li>Efficient access to <code>basic_stringbuf</code>'s buffer.</li>
</ul>
</li>
+ <li>Experimental C++23 support, including:
+ <ul>
+ <li><code>contains</code> member functions for strings,
+ thanks to Paul Fee.
+ </li>
+ </ul>
+ </li>
<li>Faster <code>std::uniform_int_distribution</code>,
thanks to Daniel Lemire.
</li>