@@ -80,7 +80,7 @@ public:
80
80
constexpr bool operator[](size_t pos) const;
81
81
reference operator[](size_t pos); // constexpr since C++23
82
82
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
84
84
template <class charT, class traits, class Allocator> // constexpr since C++23
85
85
basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;
86
86
template <class charT, class traits> // constexpr since C++23
@@ -226,30 +226,19 @@ protected:
226
226
227
227
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
228
228
229
- // unsigned long spans only one word
230
- template <typename _StorageType = __storage_type,
231
- __enable_if_t <sizeof (_StorageType) >= sizeof (unsigned long ), int > = 0 >
232
229
_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." );
233
234
return static_cast <unsigned long >(__first_[0 ]);
234
235
}
235
236
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
-
248
237
// _Bit_size > sizeof(unsigned long) * CHAR_BIT: overflow check needed
249
238
template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size > sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
250
239
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
251
240
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" );
253
242
254
243
return __to_ulong ();
255
244
}
@@ -265,7 +254,7 @@ protected:
265
254
if _LIBCPP_CONSTEXPR (_Size > sizeof (unsigned long long ) * CHAR_BIT) {
266
255
if (auto __e = __make_iter (_Size);
267
256
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" );
269
258
}
270
259
271
260
// 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)
527
516
528
517
template <size_t _Size>
529
518
inline _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 .
533
522
// See: https://github.com/llvm/llvm-project/actions/runs/15071518915/job/42368867929?pr=121348#logs
534
523
: __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v) : static_cast <__storage_type>(__v)) {}
535
524
@@ -617,8 +606,8 @@ protected:
617
606
618
607
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT {}
619
608
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 ; }
622
611
623
612
template <bool _Sparse, class _CharT , class _Traits , class _Allocator >
624
613
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
0 commit comments