@@ -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,18 @@ 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
+ " bitset only supports platforms where sizeof(size_t) >= sizeof(unsigned long), such as 32-bit and "
232
+ " 64-bit platforms" );
233
233
return static_cast <unsigned long >(__first_[0 ]);
234
234
}
235
235
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
236
// _Bit_size > sizeof(unsigned long) * CHAR_BIT: overflow check needed
249
237
template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size > sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
250
238
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
251
239
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" );
240
+ std::__throw_overflow_error (" __bitset<_N_words, _Size>::to_ulong overflow error" );
253
241
254
242
return __to_ulong ();
255
243
}
@@ -265,7 +253,7 @@ protected:
265
253
if _LIBCPP_CONSTEXPR (_Size > sizeof (unsigned long long ) * CHAR_BIT) {
266
254
if (auto __e = __make_iter (_Size);
267
255
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" );
256
+ std::__throw_overflow_error (" __bitset<_N_words, _Size>::to_ullong overflow error" );
269
257
}
270
258
271
259
// At this point, the effective bitset size (excluding leading zeros) fits in unsigned long long
@@ -527,9 +515,9 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0)
527
515
528
516
template <size_t _Size>
529
517
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 .
518
+ // TODO: We must refer to __bits_per_word in order to work around an issue with the GDB pretty-printers.
519
+ // Without it, the pretty-printers complain about a missing __bits_per_word member. This needs to
520
+ // be investigated further .
533
521
// See: https://github.com/llvm/llvm-project/actions/runs/15071518915/job/42368867929?pr=121348#logs
534
522
: __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v) : static_cast <__storage_type>(__v)) {}
535
523
@@ -617,8 +605,8 @@ protected:
617
605
618
606
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT {}
619
607
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 ; }
608
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const { return 0 ; }
609
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const { return 0 ; }
622
610
623
611
template <bool _Sparse, class _CharT , class _Traits , class _Allocator >
624
612
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
0 commit comments