@@ -223,10 +223,10 @@ protected:
223
223
224
224
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
225
225
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
226
- return to_ulong (_BoolConstant < _Size< sizeof (unsigned long ) * CHAR_BIT>());
226
+ return __to_ulong (_BoolConstant < _Size< sizeof (unsigned long ) * CHAR_BIT>());
227
227
}
228
228
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const {
229
- return to_ullong (_BoolConstant < _Size< sizeof (unsigned long long ) * CHAR_BIT>());
229
+ return __to_ullong (_BoolConstant < _Size< sizeof (unsigned long long ) * CHAR_BIT>());
230
230
}
231
231
232
232
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all () const _NOEXCEPT { return !__scan_bits (__bit_not ()); }
@@ -261,14 +261,6 @@ private:
261
261
void __init (unsigned long long __v, false_type) _NOEXCEPT;
262
262
_LIBCPP_HIDE_FROM_ABI void __init (unsigned long long __v, true_type) _NOEXCEPT;
263
263
# endif // _LIBCPP_CXX03_LANG
264
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong (false_type) const ;
265
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong (true_type) const ;
266
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong (true_type, false_type) const ;
267
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong (true_type, true_type) const ;
268
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong (false_type) const ;
269
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong (true_type) const ;
270
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong (true_type, false_type) const ;
271
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong (true_type, true_type) const ;
272
264
273
265
template <typename _Proj>
274
266
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __scan_bits (_Proj __proj) const _NOEXCEPT {
@@ -286,6 +278,15 @@ private:
286
278
}
287
279
return false ;
288
280
}
281
+
282
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (false_type) const ;
283
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type) const ;
284
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type, false_type) const ;
285
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type, true_type) const ;
286
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (false_type) const ;
287
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type) const ;
288
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type, false_type) const ;
289
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type, true_type) const ;
289
290
};
290
291
291
292
template <size_t _N_words, size_t _Size>
@@ -384,28 +385,28 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz
384
385
385
386
template <size_t _N_words, size_t _Size>
386
387
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
387
- __bitset<_N_words, _Size>::to_ulong (false_type) const {
388
+ __bitset<_N_words, _Size>::__to_ulong (false_type) const {
388
389
if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
389
- std::__throw_overflow_error (" bitset to_ulong overflow error" );
390
+ std::__throw_overflow_error (" bitset __to_ulong overflow error" );
390
391
391
- return to_ulong (true_type ());
392
+ return __to_ulong (true_type ());
392
393
}
393
394
394
395
template <size_t _N_words, size_t _Size>
395
396
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
396
- __bitset<_N_words, _Size>::to_ulong (true_type) const {
397
- return to_ulong (true_type (), _BoolConstant<sizeof (__storage_type) < sizeof (unsigned long )>());
397
+ __bitset<_N_words, _Size>::__to_ulong (true_type) const {
398
+ return __to_ulong (true_type (), _BoolConstant<sizeof (__storage_type) < sizeof (unsigned long )>());
398
399
}
399
400
400
401
template <size_t _N_words, size_t _Size>
401
402
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
402
- __bitset<_N_words, _Size>::to_ulong (true_type, false_type) const {
403
+ __bitset<_N_words, _Size>::__to_ulong (true_type, false_type) const {
403
404
return static_cast <unsigned long >(__first_[0 ]);
404
405
}
405
406
406
407
template <size_t _N_words, size_t _Size>
407
408
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
408
- __bitset<_N_words, _Size>::to_ulong (true_type, true_type) const {
409
+ __bitset<_N_words, _Size>::__to_ulong (true_type, true_type) const {
409
410
unsigned long __r = static_cast <unsigned long >(__first_[0 ]);
410
411
_LIBCPP_DIAGNOSTIC_PUSH
411
412
_LIBCPP_GCC_DIAGNOSTIC_IGNORED (" -Wshift-count-overflow" )
@@ -414,34 +415,37 @@ __bitset<_N_words, _Size>::to_ulong(true_type, true_type) const {
414
415
_LIBCPP_DIAGNOSTIC_POP
415
416
return __r;
416
417
}
418
+
417
419
template <size_t _N_words, size_t _Size>
418
420
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
419
- __bitset<_N_words, _Size>::to_ullong (false_type) const {
421
+ __bitset<_N_words, _Size>::__to_ullong (false_type) const {
420
422
if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true ) != __e)
421
- std::__throw_overflow_error (" bitset to_ullong overflow error" );
423
+ std::__throw_overflow_error (" bitset __to_ullong overflow error" );
422
424
423
- return to_ullong (true_type ());
425
+ return __to_ullong (true_type ());
424
426
}
425
427
426
428
template <size_t _N_words, size_t _Size>
427
429
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
428
- __bitset<_N_words, _Size>::to_ullong (true_type) const {
429
- return to_ullong (true_type (), _BoolConstant<sizeof (__storage_type) < sizeof (unsigned long long )>());
430
+ __bitset<_N_words, _Size>::__to_ullong (true_type) const {
431
+ return __to_ullong (true_type (), _BoolConstant<sizeof (__storage_type) < sizeof (unsigned long long )>());
430
432
}
431
433
432
434
template <size_t _N_words, size_t _Size>
433
435
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
434
- __bitset<_N_words, _Size>::to_ullong (true_type, false_type) const {
436
+ __bitset<_N_words, _Size>::__to_ullong (true_type, false_type) const {
435
437
return static_cast <unsigned long long >(__first_[0 ]);
436
438
}
437
439
438
440
template <size_t _N_words, size_t _Size>
439
441
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
440
- __bitset<_N_words, _Size>::to_ullong (true_type, true_type) const {
442
+ __bitset<_N_words, _Size>::__to_ullong (true_type, true_type) const {
441
443
unsigned long long __r = static_cast <unsigned long long >(__first_[0 ]);
442
444
_LIBCPP_DIAGNOSTIC_PUSH
443
445
_LIBCPP_GCC_DIAGNOSTIC_IGNORED (" -Wshift-count-overflow" )
444
- for (size_t __i = 1 ; __i < _N_words; ++__i)
446
+ const size_t __ull_wrods = (sizeof (unsigned long long ) - 1 ) / sizeof (__storage_type) + 1 ;
447
+ const size_t __n_words = _N_words < __ull_wrods ? _N_words : __ull_wrods;
448
+ for (size_t __i = 1 ; __i < __n_words; ++__i)
445
449
__r |= static_cast <unsigned long long >(__first_[__i]) << (__bits_per_word * __i);
446
450
_LIBCPP_DIAGNOSTIC_POP
447
451
return __r;
@@ -526,6 +530,10 @@ protected:
526
530
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any () const _NOEXCEPT;
527
531
528
532
_LIBCPP_HIDE_FROM_ABI size_t __hash_code () const _NOEXCEPT;
533
+
534
+ private:
535
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (false_type) const ;
536
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type) const ;
529
537
};
530
538
531
539
template <size_t _Size>
@@ -560,6 +568,19 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Siz
560
568
561
569
template <size_t _Size>
562
570
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1 , _Size>::to_ulong() const {
571
+ return __to_ulong (_BoolConstant < _Size< sizeof (unsigned long ) * CHAR_BIT>());
572
+ }
573
+
574
+ template <size_t _Size>
575
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1 , _Size>::__to_ulong(false_type) const {
576
+ if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
577
+ __throw_overflow_error (" __bitset<1, _Size>::__to_ulong overflow error" );
578
+
579
+ return static_cast <unsigned long >(__first_);
580
+ }
581
+
582
+ template <size_t _Size>
583
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1 , _Size>::__to_ulong(true_type) const {
563
584
return static_cast <unsigned long >(__first_);
564
585
}
565
586
0 commit comments