@@ -80,7 +80,7 @@ public:
8080 constexpr bool operator[](size_t pos) const;
8181 reference operator[](size_t pos); // constexpr since C++23
8282 unsigned long to_ulong() const; // constexpr since C++23
83- unsigned long long to_ullong() const; // since C++11, constexpr since C++23
83+ unsigned long long to_ullong() const; // constexpr since C++23
8484 template <class charT, class traits, class Allocator> // constexpr since C++23
8585 basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;
8686 template <class charT, class traits> // constexpr since C++23
@@ -226,30 +226,19 @@ protected:
226226
227227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
228228
229- // unsigned long spans only one word
230- template <typename _StorageType = __storage_type,
231- __enable_if_t <sizeof (_StorageType) >= sizeof (unsigned long ), int > = 0 >
232229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong () const {
230+ static_assert (sizeof (__storage_type) >= sizeof (unsigned long ),
231+ " libc++ only supports platforms where sizeof(size_t) >= sizeof(unsigned long), such as 32-bit and "
232+ " 64-bit platforms. If you're interested in supporting a platform where that is not the case, please "
233+ " contact the libc++ developers." );
233234 return static_cast <unsigned long >(__first_[0 ]);
234235 }
235236
236- // unsigned long may span multiple words which are concatenated to form the result
237- template <typename _StorageType = __storage_type,
238- __enable_if_t <sizeof (_StorageType) < sizeof (unsigned long ), int > = 0 >
239- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong () const {
240- const size_t __ul_words = (sizeof (unsigned long ) - 1 ) / sizeof (__storage_type) + 1 ;
241- const size_t __n_words = _N_words < __ul_words ? _N_words : __ul_words;
242- unsigned long __r = static_cast <unsigned long >(__first_[0 ]);
243- for (size_t __i = 1 ; __i < __n_words; ++__i)
244- __r |= static_cast <unsigned long >(__first_[__i]) << (__bits_per_word * __i);
245- return __r;
246- }
247-
248237 // _Bit_size > sizeof(unsigned long) * CHAR_BIT: overflow check needed
249238 template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size > sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
250239 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
251240 if (auto __e = __make_iter (_Bit_size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
252- std::__throw_overflow_error (" __bitset<_N_words, _Size>::__to_ulong overflow error" );
241+ std::__throw_overflow_error (" __bitset<_N_words, _Size>::to_ulong overflow error" );
253242
254243 return __to_ulong ();
255244 }
@@ -265,7 +254,7 @@ protected:
265254 if _LIBCPP_CONSTEXPR (_Size > sizeof (unsigned long long ) * CHAR_BIT) {
266255 if (auto __e = __make_iter (_Size);
267256 std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true ) != __e)
268- std::__throw_overflow_error (" __bitset<_N_words, _Size>::__to_ullong overflow error" );
257+ std::__throw_overflow_error (" __bitset<_N_words, _Size>::to_ullong overflow error" );
269258 }
270259
271260 // At this point, the effective bitset size (excluding leading zeros) fits in unsigned long long
@@ -527,9 +516,9 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0)
527516
528517template <size_t _Size>
529518inline _LIBCPP_CONSTEXPR __bitset<1 , _Size>::__bitset(unsigned long long __v) _NOEXCEPT
530- // TODO: This is a workaround for a gdb test failure (gdb_pretty_printer_test.sh.cpp) in
531- // stage1 CI (generic-gcc, gcc-14, g++-14), due to the __bits_per_word name lookup failure
532- // if not referenced in the constructor initializer list .
519+ // TODO: We must refer to __bits_per_word in order to work around an issue with the GDB pretty-printers.
520+ // Without it, the pretty-printers complain about a missing __bits_per_word member. This needs to
521+ // be investigated further .
533522 // See: https://github.com/llvm/llvm-project/actions/runs/15071518915/job/42368867929?pr=121348#logs
534523 : __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v) : static_cast <__storage_type>(__v)) {}
535524
@@ -617,8 +606,8 @@ protected:
617606
618607 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT {}
619608
620- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const { return 0UL ; }
621- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const { return 0ULL ; }
609+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const { return 0 ; }
610+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const { return 0 ; }
622611
623612 template <bool _Sparse, class _CharT , class _Traits , class _Allocator >
624613 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
0 commit comments