@@ -144,6 +144,7 @@ template <size_t N> struct hash<std::bitset<N>>;
144
144
# include < __cstddef/size_t.h>
145
145
# include < __functional/hash.h>
146
146
# include < __functional/unary_function.h>
147
+ # include < __type_traits/integral_constant.h>
147
148
# include < __type_traits/is_char_like_type.h>
148
149
# include < climits>
149
150
# include < stdexcept>
@@ -219,10 +220,10 @@ protected:
219
220
220
221
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
221
222
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
222
- return to_ulong (integral_constant < bool , _Size< sizeof (unsigned long ) * CHAR_BIT>());
223
+ return to_ulong (_BoolConstant < _Size< sizeof (unsigned long ) * CHAR_BIT>());
223
224
}
224
225
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const {
225
- return to_ullong (integral_constant < bool , _Size< sizeof (unsigned long long ) * CHAR_BIT>());
226
+ return to_ullong (_BoolConstant < _Size< sizeof (unsigned long long ) * CHAR_BIT>());
226
227
}
227
228
228
229
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all () const _NOEXCEPT;
@@ -309,7 +310,7 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long
309
310
# endif
310
311
{
311
312
# ifdef _LIBCPP_CXX03_LANG
312
- __init (__v, integral_constant< bool , sizeof (unsigned long long ) == sizeof (__storage_type)>());
313
+ __init (__v, _BoolConstant< sizeof (unsigned long long ) == sizeof (__storage_type)>());
313
314
# endif
314
315
}
315
316
@@ -351,9 +352,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz
351
352
template <size_t _N_words, size_t _Size>
352
353
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
353
354
__bitset<_N_words, _Size>::to_ulong(false_type) const {
354
- __const_iterator __e = __make_iter (_Size);
355
- __const_iterator __i = std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true );
356
- if (__i != __e)
355
+ if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
357
356
std::__throw_overflow_error (" bitset to_ulong overflow error" );
358
357
359
358
return to_ulong (true_type ());
@@ -362,7 +361,7 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const {
362
361
template <size_t _N_words, size_t _Size>
363
362
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
364
363
__bitset<_N_words, _Size>::to_ulong(true_type) const {
365
- return to_ulong (true_type (), integral_constant< bool , sizeof (__storage_type) < sizeof (unsigned long )>());
364
+ return to_ulong (true_type (), _BoolConstant< sizeof (__storage_type) < sizeof (unsigned long )>());
366
365
}
367
366
368
367
template <size_t _N_words, size_t _Size>
@@ -377,19 +376,15 @@ __bitset<_N_words, _Size>::to_ulong(true_type, true_type) const {
377
376
unsigned long __r = static_cast <unsigned long >(__first_[0 ]);
378
377
_LIBCPP_DIAGNOSTIC_PUSH
379
378
_LIBCPP_GCC_DIAGNOSTIC_IGNORED (" -Wshift-count-overflow" )
380
- const size_t __ul_words = sizeof (unsigned long ) / sizeof (__storage_type);
381
- const size_t __n_words = _N_words < __ul_words ? _N_words : __ul_words;
382
- for (size_t __i = 1 ; __i < __n_words; ++__i)
379
+ for (size_t __i = 1 ; __i < _N_words; ++__i)
383
380
__r |= static_cast <unsigned long >(__first_[__i]) << (__bits_per_word * __i);
384
381
_LIBCPP_DIAGNOSTIC_POP
385
382
return __r;
386
383
}
387
384
template <size_t _N_words, size_t _Size>
388
385
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
389
386
__bitset<_N_words, _Size>::to_ullong(false_type) const {
390
- __const_iterator __e = __make_iter (_Size);
391
- __const_iterator __i = std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true );
392
- if (__i != __e)
387
+ if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true ) != __e)
393
388
std::__throw_overflow_error (" bitset to_ullong overflow error" );
394
389
395
390
return to_ullong (true_type ());
@@ -398,7 +393,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const {
398
393
template <size_t _N_words, size_t _Size>
399
394
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
400
395
__bitset<_N_words, _Size>::to_ullong(true_type) const {
401
- return to_ullong (true_type (), integral_constant< bool , sizeof (__storage_type) < sizeof (unsigned long long )>());
396
+ return to_ullong (true_type (), _BoolConstant< sizeof (__storage_type) < sizeof (unsigned long long )>());
402
397
}
403
398
404
399
template <size_t _N_words, size_t _Size>
@@ -413,9 +408,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
413
408
unsigned long long __r = static_cast <unsigned long long >(__first_[0 ]);
414
409
_LIBCPP_DIAGNOSTIC_PUSH
415
410
_LIBCPP_GCC_DIAGNOSTIC_IGNORED (" -Wshift-count-overflow" )
416
- const size_t __ull_words = sizeof (unsigned long long ) / sizeof (__storage_type);
417
- const size_t __n_words = _N_words < __ull_words ? _N_words : __ull_words;
418
- for (size_t __i = 1 ; __i < __n_words; ++__i)
411
+ for (size_t __i = 1 ; __i < _N_words; ++__i)
419
412
__r |= static_cast <unsigned long long >(__first_[__i]) << (__bits_per_word * __i);
420
413
_LIBCPP_DIAGNOSTIC_POP
421
414
return __r;
@@ -523,11 +516,7 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0)
523
516
524
517
template <size_t _Size>
525
518
inline _LIBCPP_CONSTEXPR __bitset<1 , _Size>::__bitset(unsigned long long __v) _NOEXCEPT
526
- : __first_(static_cast <__storage_type>(__v)) {
527
- // Force __bits_per_word to be instantiated to avoid "gdb.error: There is no member or method named
528
- // __bits_per_word"
529
- (void )__bits_per_word;
530
- }
519
+ : __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v) : static_cast <__storage_type>(__v)) {}
531
520
532
521
template <size_t _Size>
533
522
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
0 commit comments