@@ -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; // constexpr since C++23
83
+ unsigned long long to_ullong() const; // since C++11, 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
@@ -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 < __tuple/tuple_indices.h>
150
151
# include < __type_traits/enable_if.h>
151
152
# include < __type_traits/integral_constant.h>
152
153
# include < __type_traits/is_char_like_type.h>
@@ -224,12 +225,66 @@ protected:
224
225
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator ^=(const __bitset& __v) _NOEXCEPT;
225
226
226
227
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
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
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong () const {
233
+ return static_cast <unsigned long >(__first_[0 ]);
234
+ }
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
+ // _Bit_size > sizeof(unsigned long) * CHAR_BIT: overflow check needed
249
+ template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size > sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
250
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
251
+ 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" );
253
+
254
+ return __to_ulong ();
255
+ }
256
+
257
+ // _Bit_size <= sizeof(unsigned long) * CHAR_BIT: no overflow check needed
258
+ template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size <= sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
227
259
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
228
- return __to_ulong (_BoolConstant<_Size <= sizeof ( unsigned long ) * CHAR_BIT>() );
260
+ return __to_ulong ();
229
261
}
262
+
263
+ # ifndef _LIBCPP_CXX03_LANG
230
264
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const {
231
- return __to_ullong (_BoolConstant<_Size <= sizeof (unsigned long long ) * CHAR_BIT>());
265
+ // Check for overflow if _Size does not fit in unsigned long long
266
+ if _LIBCPP_CONSTEXPR (_Size > sizeof (unsigned long long ) * CHAR_BIT) {
267
+ if (auto __e = __make_iter (_Size);
268
+ std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true ) != __e)
269
+ std::__throw_overflow_error (" __bitset<_N_words, _Size>::__to_ullong overflow error" );
270
+ }
271
+
272
+ // At this point, the effective bitset size (excluding leading zeros) fits in unsigned long long
273
+
274
+ if _LIBCPP_CONSTEXPR (sizeof (__storage_type) >= sizeof (unsigned long long )) {
275
+ // If __storage_type is at least as large as unsigned long long, the result spans only one word
276
+ return static_cast <unsigned long long >(__first_[0 ]);
277
+ } else {
278
+ // Otherwise, the result spans multiple words which are concatenated
279
+ const size_t __ull_words = (sizeof (unsigned long long ) - 1 ) / sizeof (__storage_type) + 1 ;
280
+ const size_t __n_words = _N_words < __ull_words ? _N_words : __ull_words;
281
+ unsigned long long __r = static_cast <unsigned long long >(__first_[0 ]);
282
+ for (size_t __i = 1 ; __i < __n_words; ++__i)
283
+ __r |= static_cast <unsigned long long >(__first_[__i]) << (__bits_per_word * __i);
284
+ return __r;
285
+ }
232
286
}
287
+ # endif
233
288
234
289
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all () const _NOEXCEPT { return !__scan_bits (__bit_not ()); }
235
290
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any () const _NOEXCEPT {
@@ -259,10 +314,6 @@ private:
259
314
return ~__x;
260
315
}
261
316
};
262
- # ifdef _LIBCPP_CXX03_LANG
263
- void __init (unsigned long long __v, false_type) _NOEXCEPT;
264
- _LIBCPP_HIDE_FROM_ABI void __init (unsigned long long __v, true_type) _NOEXCEPT;
265
- # endif // _LIBCPP_CXX03_LANG
266
317
267
318
template <typename _Proj>
268
319
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __scan_bits (_Proj __proj) const _NOEXCEPT {
@@ -281,6 +332,10 @@ private:
281
332
return false ;
282
333
}
283
334
335
+ # ifdef _LIBCPP_CXX03_LANG
336
+ void __init (unsigned long long __v, false_type) _NOEXCEPT;
337
+ _LIBCPP_HIDE_FROM_ABI void __init (unsigned long long __v, true_type) _NOEXCEPT;
338
+
284
339
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (false_type) const ;
285
340
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type) const ;
286
341
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type, false_type) const ;
@@ -289,11 +344,11 @@ private:
289
344
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type) const ;
290
345
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type, false_type) const ;
291
346
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type, true_type) const ;
292
- # if _LIBCPP_STD_VER >= 14
347
+ # else
293
348
template <size_t ... _Indices>
294
- _LIBCPP_HIDE_FROM_ABI constexpr __bitset (unsigned long long __v, std::index_sequence <_Indices...>) _NOEXCEPT
349
+ _LIBCPP_HIDE_FROM_ABI constexpr __bitset (unsigned long long __v, std::__tuple_indices <_Indices...>) _NOEXCEPT
295
350
: __first_{static_cast <__storage_type>(__v >> (_Indices * __bits_per_word))...} {}
296
- # endif
351
+ # endif // _LIBCPP_CXX03_LANG
297
352
};
298
353
299
354
template <size_t _N_words, size_t _Size>
@@ -325,47 +380,20 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon
325
380
326
381
# endif // _LIBCPP_CXX03_LANG
327
382
328
- # ifdef _LIBCPP_CXX03_LANG
329
383
template <size_t _N_words, size_t _Size>
330
- inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT {
384
+ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
385
+ # ifndef _LIBCPP_CXX03_LANG
386
+ : __bitset(__v,
387
+ std::__make_indices_imp< (_N_words < (sizeof (unsigned long long ) - 1 ) / sizeof (__storage_type) + 1 )
388
+ ? _N_words
389
+ : (sizeof (unsigned long long ) - 1 ) / sizeof (__storage_type) + 1 ,
390
+ 0 >{})
391
+ # endif
392
+ {
393
+ # ifdef _LIBCPP_CXX03_LANG
331
394
__init (__v, _BoolConstant<sizeof (unsigned long long ) == sizeof (__storage_type)>());
395
+ # endif
332
396
}
333
- # elif _LIBCPP_STD_VER >= 14
334
- template <size_t _N_words, size_t _Size>
335
- inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
336
- : __bitset{__v,
337
- std::make_index_sequence<
338
- std::min<size_t >(_N_words, (sizeof (unsigned long long ) - 1 ) / sizeof (__storage_type) + 1 )>{}} {}
339
- # else
340
- # if __SIZEOF_LONG_LONG__ <= __SIZEOF_SIZE_T__
341
- template <size_t _N_words, size_t _Size>
342
- inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
343
- : __first_{static_cast <__storage_type>(__v)} {}
344
- # elif __SIZEOF_LONG_LONG__ == 2 * __SIZEOF_SIZE_T__
345
- template <size_t _N_words, size_t _Size>
346
- inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
347
- : __first_{static_cast <__storage_type>(__v), static_cast <__storage_type>(__v >> __bits_per_word)} {}
348
- # elif __SIZEOF_LONG_LONG__ == 4 * __SIZEOF_SIZE_T__
349
- template <size_t _N_words, size_t _Size, __enable_if_t <_N_words == 2 , int > = 0 >
350
- inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
351
- : __first_{static_cast <__storage_type>(__v), static_cast <__storage_type>(__v >> __bits_per_word)} {}
352
-
353
- template <size_t _N_words, size_t _Size, __enable_if_t <_N_words == 3 , int > = 0 >
354
- inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
355
- : __first_{static_cast <__storage_type>(__v),
356
- static_cast <__storage_type>(__v >> __bits_per_word),
357
- static_cast <__storage_type>(__v >> (__bits_per_word * 2 ))} {}
358
-
359
- template <size_t _N_words, size_t _Size, __enable_if_t <_N_words >= 4 , int > = 0 >
360
- inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
361
- : __first_{static_cast <__storage_type>(__v),
362
- static_cast <__storage_type>(__v >> __bits_per_word),
363
- static_cast <__storage_type>(__v >> (__bits_per_word * 2 )),
364
- static_cast <__storage_type>(__v >> (__bits_per_word * 3 ))} {}
365
- # else
366
- # error This constructor has not been ported to this platform
367
- # endif
368
- # endif // _LIBCPP_CXX03_LANG
369
397
370
398
template <size_t _N_words, size_t _Size>
371
399
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
@@ -402,70 +430,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz
402
430
*__p ^= (__storage_type (1 ) << __n) - 1 ;
403
431
}
404
432
405
- template <size_t _N_words, size_t _Size>
406
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
407
- __bitset<_N_words, _Size>::__to_ulong(false_type) const {
408
- if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
409
- std::__throw_overflow_error (" bitset __to_ulong overflow error" );
410
-
411
- return __to_ulong (true_type ());
412
- }
413
-
414
- template <size_t _N_words, size_t _Size>
415
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
416
- __bitset<_N_words, _Size>::__to_ulong(true_type) const {
417
- return __to_ulong (true_type (), _BoolConstant<sizeof (__storage_type) < sizeof (unsigned long )>());
418
- }
419
-
420
- template <size_t _N_words, size_t _Size>
421
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
422
- __bitset<_N_words, _Size>::__to_ulong(true_type, false_type) const {
423
- return static_cast <unsigned long >(__first_[0 ]);
424
- }
425
-
426
- template <size_t _N_words, size_t _Size>
427
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
428
- __bitset<_N_words, _Size>::__to_ulong(true_type, true_type) const {
429
- const size_t __ul_wrods = (sizeof (unsigned long ) - 1 ) / sizeof (__storage_type) + 1 ;
430
- const size_t __n_words = _N_words < __ul_wrods ? _N_words : __ul_wrods;
431
- unsigned long __r = static_cast <unsigned long >(__first_[0 ]);
432
- for (size_t __i = 1 ; __i < __n_words; ++__i)
433
- __r |= static_cast <unsigned long >(__first_[__i]) << (__bits_per_word * __i);
434
- return __r;
435
- }
436
-
437
- template <size_t _N_words, size_t _Size>
438
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
439
- __bitset<_N_words, _Size>::__to_ullong(false_type) const {
440
- if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true ) != __e)
441
- std::__throw_overflow_error (" bitset __to_ullong overflow error" );
442
-
443
- return __to_ullong (true_type ());
444
- }
445
-
446
- template <size_t _N_words, size_t _Size>
447
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
448
- __bitset<_N_words, _Size>::__to_ullong(true_type) const {
449
- return __to_ullong (true_type (), _BoolConstant<sizeof (__storage_type) < sizeof (unsigned long long )>());
450
- }
451
-
452
- template <size_t _N_words, size_t _Size>
453
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
454
- __bitset<_N_words, _Size>::__to_ullong(true_type, false_type) const {
455
- return static_cast <unsigned long long >(__first_[0 ]);
456
- }
457
-
458
- template <size_t _N_words, size_t _Size>
459
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
460
- __bitset<_N_words, _Size>::__to_ullong(true_type, true_type) const {
461
- const size_t __ull_wrods = (sizeof (unsigned long long ) - 1 ) / sizeof (__storage_type) + 1 ;
462
- const size_t __n_words = _N_words < __ull_wrods ? _N_words : __ull_wrods;
463
- unsigned long long __r = static_cast <unsigned long long >(__first_[0 ]);
464
- for (size_t __i = 1 ; __i < __n_words; ++__i)
465
- __r |= static_cast <unsigned long long >(__first_[__i]) << (__bits_per_word * __i);
466
- return __r;
467
- }
468
-
469
433
template <size_t _N_words, size_t _Size>
470
434
inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT {
471
435
size_t __h = 0 ;
@@ -524,8 +488,32 @@ protected:
524
488
525
489
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
526
490
527
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const ;
528
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const ;
491
+ template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size > sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
492
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
493
+ if (auto __e = __make_iter (_Bit_size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
494
+ __throw_overflow_error (" __bitset<1, _Size>::to_ulong overflow error" );
495
+
496
+ return static_cast <unsigned long >(__first_);
497
+ }
498
+
499
+ template <size_t _Bit_size = _Size, __enable_if_t <(_Bit_size <= sizeof (unsigned long ) * CHAR_BIT), int > = 0 >
500
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const {
501
+ return static_cast <unsigned long >(__first_);
502
+ }
503
+
504
+ # ifndef _LIBCPP_CXX03_LANG
505
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const {
506
+ // If _Size exceeds the size of unsigned long long, check for overflow
507
+ if _LIBCPP_CONSTEXPR (_Size > sizeof (unsigned long long ) * CHAR_BIT) {
508
+ if (auto __e = __make_iter (_Size);
509
+ std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true ) != __e)
510
+ __throw_overflow_error (" __bitset<1, _Size>::to_ullong overflow error" );
511
+ }
512
+
513
+ // If _Size fits or no overflow, directly cast to unsigned long long
514
+ return static_cast <unsigned long long >(__first_);
515
+ }
516
+ # endif
529
517
530
518
template <bool _Sparse, class _CharT , class _Traits , class _Allocator >
531
519
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
@@ -545,19 +533,16 @@ protected:
545
533
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any () const _NOEXCEPT;
546
534
547
535
_LIBCPP_HIDE_FROM_ABI size_t __hash_code () const _NOEXCEPT;
548
-
549
- private:
550
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (false_type) const ;
551
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type) const ;
552
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (false_type) const ;
553
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type) const ;
554
536
};
555
537
556
538
template <size_t _Size>
557
539
inline _LIBCPP_CONSTEXPR __bitset<1 , _Size>::__bitset() _NOEXCEPT : __first_(0 ) {}
558
540
559
541
template <size_t _Size>
560
542
inline _LIBCPP_CONSTEXPR __bitset<1 , _Size>::__bitset(unsigned long long __v) _NOEXCEPT
543
+ // TODO: This is a workaround for a GCC bug causing stage1 CI (generic-gcc, gcc-14, g++-14)
544
+ // failure due to __bits_per_word lookup failure if not referenced here.
545
+ // See: https://github.com/llvm/llvm-project/actions/runs/15071518915/job/42368867929?pr=121348#logs
561
546
: __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v) : static_cast <__storage_type>(__v)) {}
562
547
563
548
template <size_t _Size>
@@ -583,44 +568,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Siz
583
568
__first_ ^= ~__storage_type (0 ) >> (__bits_per_word - _Size);
584
569
}
585
570
586
- template <size_t _Size>
587
- inline _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1 , _Size>::to_ulong() const {
588
- return __to_ulong (_BoolConstant<_Size <= sizeof (unsigned long ) * CHAR_BIT>());
589
- }
590
-
591
- template <size_t _Size>
592
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1 , _Size>::__to_ulong(false_type) const {
593
- if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long ) * CHAR_BIT), __e, true ) != __e)
594
- __throw_overflow_error (" __bitset<1, _Size>::__to_ulong overflow error" );
595
-
596
- return static_cast <unsigned long >(__first_);
597
- }
598
-
599
- template <size_t _Size>
600
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1 , _Size>::__to_ulong(true_type) const {
601
- return static_cast <unsigned long >(__first_);
602
- }
603
-
604
- template <size_t _Size>
605
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __bitset<1 , _Size>::to_ullong() const {
606
- return __to_ullong (_BoolConstant<_Size <= sizeof (unsigned long long ) * CHAR_BIT>());
607
- }
608
-
609
- template <size_t _Size>
610
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
611
- __bitset<1 , _Size>::__to_ullong(false_type) const {
612
- if (auto __e = __make_iter (_Size); std::find (__make_iter (sizeof (unsigned long long ) * CHAR_BIT), __e, true ) != __e)
613
- __throw_overflow_error (" __bitset<1, _Size>::__to_ullong overflow error" );
614
-
615
- return static_cast <unsigned long long >(__first_);
616
- }
617
-
618
- template <size_t _Size>
619
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
620
- __bitset<1 , _Size>::__to_ullong(true_type) const {
621
- return static_cast <unsigned long long >(__first_);
622
- }
623
-
624
571
template <size_t _Size>
625
572
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<1 , _Size>::all() const _NOEXCEPT {
626
573
__storage_type __m = ~__storage_type (0 ) >> (__bits_per_word - _Size);
@@ -683,7 +630,9 @@ protected:
683
630
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT {}
684
631
685
632
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const { return 0UL ; }
633
+ # ifndef _LIBCPP_CXX03_LANG
686
634
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const { return 0ULL ; }
635
+ # endif
687
636
688
637
template <bool _Sparse, class _CharT , class _Traits , class _Allocator >
689
638
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
@@ -794,8 +743,12 @@ public:
794
743
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (__p < _Size, " bitset::operator[] index out of bounds" );
795
744
return __base::__make_ref (__p);
796
745
}
797
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const ;
798
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const ;
746
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const { return __base::to_ulong (); }
747
+ # ifndef _LIBCPP_CXX03_LANG
748
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const {
749
+ return __base::to_ullong ();
750
+ }
751
+ # endif
799
752
template <class _CharT , class _Traits , class _Allocator >
800
753
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
801
754
to_string (_CharT __zero = _CharT(' 0' ), _CharT __one = _CharT(' 1' )) const ;
@@ -931,16 +884,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>
931
884
return *this ;
932
885
}
933
886
934
- template <size_t _Size>
935
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const {
936
- return __base::to_ulong ();
937
- }
938
-
939
- template <size_t _Size>
940
- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const {
941
- return __base::to_ullong ();
942
- }
943
-
944
887
template <size_t _Size>
945
888
template <class _CharT , class _Traits , class _Allocator >
946
889
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
0 commit comments