@@ -147,6 +147,7 @@ template <size_t N> struct hash<std::bitset<N>>;
147
147
# include < __functional/hash.h>
148
148
# include < __functional/identity.h>
149
149
# include < __functional/unary_function.h>
150
+ # include < __type_traits/integral_constant.h>
150
151
# include < __type_traits/is_char_like_type.h>
151
152
# include < climits>
152
153
# include < stdexcept>
@@ -222,10 +223,10 @@ protected:
222
223
223
224
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
224
225
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
225
- return to_ulong (integral_constant < bool , _Size< sizeof (unsigned long ) * CHAR_BIT>());
226
+ return to_ulong (_BoolConstant < _Size< sizeof (unsigned long ) * CHAR_BIT>());
226
227
}
227
228
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const {
228
- return to_ullong (integral_constant < bool , _Size< sizeof (unsigned long long ) * CHAR_BIT>());
229
+ return to_ullong (_BoolConstant < _Size< sizeof (unsigned long long ) * CHAR_BIT>());
229
230
}
230
231
231
232
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all () const _NOEXCEPT { return !__scan_bits (__bit_not ()); }
@@ -342,7 +343,7 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long
342
343
# endif
343
344
{
344
345
# ifdef _LIBCPP_CXX03_LANG
345
- __init (__v, integral_constant< bool , sizeof (unsigned long long ) <= sizeof (__storage_type)>());
346
+ __init (__v, _BoolConstant< sizeof (unsigned long long ) <= sizeof (__storage_type)>());
346
347
# endif
347
348
}
348
349
@@ -384,9 +385,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz
384
385
template <size_t _N_words, size_t _Size>
385
386
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
386
387
__bitset<_N_words, _Size>::to_ulong(false_type) const {
387
- __const_iterator __e = __make_iter (_Size);
388
- __const_iterator __i = std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true );
389
- if (__i != __e)
388
+ if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
390
389
std::__throw_overflow_error (" bitset to_ulong overflow error" );
391
390
392
391
return to_ulong (true_type ());
@@ -395,7 +394,7 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const {
395
394
template <size_t _N_words, size_t _Size>
396
395
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
397
396
__bitset<_N_words, _Size>::to_ulong(true_type) const {
398
- return to_ulong (true_type (), integral_constant< bool , sizeof (__storage_type) < sizeof (unsigned long )>());
397
+ return to_ulong (true_type (), _BoolConstant< sizeof (__storage_type) < sizeof (unsigned long )>());
399
398
}
400
399
401
400
template <size_t _N_words, size_t _Size>
@@ -410,19 +409,15 @@ __bitset<_N_words, _Size>::to_ulong(true_type, true_type) const {
410
409
unsigned long __r = static_cast <unsigned long >(__first_[0 ]);
411
410
_LIBCPP_DIAGNOSTIC_PUSH
412
411
_LIBCPP_GCC_DIAGNOSTIC_IGNORED (" -Wshift-count-overflow" )
413
- const size_t __ul_words = sizeof (unsigned long ) / sizeof (__storage_type);
414
- const size_t __n_words = _N_words < __ul_words ? _N_words : __ul_words;
415
- for (size_t __i = 1 ; __i < __n_words; ++__i)
412
+ for (size_t __i = 1 ; __i < _N_words; ++__i)
416
413
__r |= static_cast <unsigned long >(__first_[__i]) << (__bits_per_word * __i);
417
414
_LIBCPP_DIAGNOSTIC_POP
418
415
return __r;
419
416
}
420
417
template <size_t _N_words, size_t _Size>
421
418
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
422
419
__bitset<_N_words, _Size>::to_ullong(false_type) const {
423
- __const_iterator __e = __make_iter (_Size);
424
- __const_iterator __i = std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true );
425
- if (__i != __e)
420
+ if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true ) != __e)
426
421
std::__throw_overflow_error (" bitset to_ullong overflow error" );
427
422
428
423
return to_ullong (true_type ());
@@ -431,7 +426,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const {
431
426
template <size_t _N_words, size_t _Size>
432
427
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
433
428
__bitset<_N_words, _Size>::to_ullong(true_type) const {
434
- return to_ullong (true_type (), integral_constant< bool , sizeof (__storage_type) < sizeof (unsigned long long )>());
429
+ return to_ullong (true_type (), _BoolConstant< sizeof (__storage_type) < sizeof (unsigned long long )>());
435
430
}
436
431
437
432
template <size_t _N_words, size_t _Size>
@@ -446,9 +441,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
446
441
unsigned long long __r = static_cast <unsigned long long >(__first_[0 ]);
447
442
_LIBCPP_DIAGNOSTIC_PUSH
448
443
_LIBCPP_GCC_DIAGNOSTIC_IGNORED (" -Wshift-count-overflow" )
449
- const size_t __ull_words = sizeof (unsigned long long ) / sizeof (__storage_type);
450
- const size_t __n_words = _N_words < __ull_words ? _N_words : __ull_words;
451
- for (size_t __i = 1 ; __i < __n_words; ++__i)
444
+ for (size_t __i = 1 ; __i < _N_words; ++__i)
452
445
__r |= static_cast <unsigned long long >(__first_[__i]) << (__bits_per_word * __i);
453
446
_LIBCPP_DIAGNOSTIC_POP
454
447
return __r;
@@ -540,11 +533,7 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0)
540
533
541
534
template <size_t _Size>
542
535
inline _LIBCPP_CONSTEXPR __bitset<1 , _Size>::__bitset(unsigned long long __v) _NOEXCEPT
543
- : __first_(static_cast <__storage_type>(__v)) {
544
- // Force __bits_per_word to be instantiated to avoid "gdb.error: There is no member or method named
545
- // __bits_per_word"
546
- (void )__bits_per_word;
547
- }
536
+ : __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v) : static_cast <__storage_type>(__v)) {}
548
537
549
538
template <size_t _Size>
550
539
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
0 commit comments