[gcc r16-2294] libstdc++: Use basic_string_view for std::bitset deduced types
Jonathan Wakely
redi@gcc.gnu.org
Wed Jul 16 12:10:52 GMT 2025
https://gcc.gnu.org/g:7c3081960922d9bd3ea81a9f8ca6e00c23170a2b
commit r16-2294-g7c3081960922d9bd3ea81a9f8ca6e00c23170a2b
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sat Jul 12 13:12:09 2025 +0100
libstdc++: Use basic_string_view for std::bitset deduced types
This change was part of by P2697R1 (Interfacing bitset with string_view)
and should be slightly cheaper to instantiate.
We should consider using basic_string_view for C++17, C++20, and C++23
as well. This patch just conservatively changes it for C++26 to match
the working draft. It's conceivable that a program-defined
specialization of basic_string<_CharT> or basic_string_view<_CharT> will
observe a difference and be affected by this change.
libstdc++-v3/ChangeLog:
* include/std/bitset (__bitset::__string) [__cpp_lib_bitset]:
Change alias to refer to basic_string_view instead.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Diff:
---
libstdc++-v3/include/std/bitset | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 1c1e1670c33f..93a03f6b5d72 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -720,7 +720,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
namespace __bitset
{
-#if _GLIBCXX_HOSTED
+#ifdef __cpp_lib_bitset // ...construct from string_view
+ template<typename _CharT>
+ using __string = std::basic_string_view<_CharT>;
+#elif _GLIBCXX_HOSTED
template<typename _CharT>
using __string = std::basic_string<_CharT>;
#else
More information about the Libstdc++-cvs
mailing list