@@ -226,29 +226,19 @@ protected:
226
226
227
227
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
228
228
229
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong () const {
229
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
230
+ if _LIBCPP_CONSTEXPR (_Size > sizeof (unsigned long ) * CHAR_BIT) {
231
+ if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
232
+ std::__throw_overflow_error (" __bitset<_N_words, _Size>::to_ulong overflow error" );
233
+ }
234
+
230
235
static_assert (sizeof (__storage_type) >= sizeof (unsigned long ),
231
236
" libc++ only supports platforms where sizeof(size_t) >= sizeof(unsigned long), such as 32-bit and "
232
237
" 64-bit platforms. If you're interested in supporting a platform where that is not the case, please "
233
238
" contact the libc++ developers." );
234
239
return static_cast <unsigned long >(__first_[0 ]);
235
240
}
236
241
237
- // _Bit_size > sizeof(unsigned long) * CHAR_BIT: overflow check needed
238
- template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size > sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
239
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
240
- if (auto __e = __make_iter (_Bit_size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
241
- std::__throw_overflow_error (" __bitset<_N_words, _Size>::to_ulong overflow error" );
242
-
243
- return __to_ulong ();
244
- }
245
-
246
- // _Bit_size <= sizeof(unsigned long) * CHAR_BIT: no overflow check needed
247
- template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size <= sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
248
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
249
- return __to_ulong ();
250
- }
251
-
252
242
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const {
253
243
// Check for overflow if _Size does not fit in unsigned long long
254
244
if _LIBCPP_CONSTEXPR (_Size > sizeof (unsigned long long ) * CHAR_BIT) {
@@ -466,16 +456,11 @@ protected:
466
456
467
457
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
468
458
469
- template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size > sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
470
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
471
- if (auto __e = __make_iter (_Bit_size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
472
- __throw_overflow_error (" __bitset<1, _Size>::to_ulong overflow error" );
473
-
474
- return static_cast <unsigned long >(__first_);
475
- }
476
-
477
- template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size <= sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
478
459
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
460
+ if _LIBCPP_CONSTEXPR (_Size > sizeof (unsigned long ) * CHAR_BIT) {
461
+ if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
462
+ __throw_overflow_error (" __bitset<1, _Size>::to_ulong overflow error" );
463
+ }
479
464
return static_cast <unsigned long >(__first_);
480
465
}
481
466
@@ -519,7 +504,6 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _N
519
504
// TODO: We must refer to __bits_per_word in order to work around an issue with the GDB pretty-printers.
520
505
// Without it, the pretty-printers complain about a missing __bits_per_word member. This needs to
521
506
// be investigated further.
522
- // See: https://github.com/llvm/llvm-project/actions/runs/15071518915/job/42368867929?pr=121348#logs
523
507
: __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v) : static_cast <__storage_type>(__v)) {}
524
508
525
509
template <size_t _Size>
0 commit comments