@@ -80,7 +80,7 @@ public:
8080 constexpr bool operator[](size_t pos) const;
8181 reference operator[](size_t pos); // constexpr since C++23
8282 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
8484 template <class charT, class traits, class Allocator> // constexpr since C++23
8585 basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;
8686 template <class charT, class traits> // constexpr since C++23
@@ -147,6 +147,7 @@ template <size_t N> struct hash<std::bitset<N>>;
147147# include < __functional/hash.h>
148148# include < __functional/identity.h>
149149# include < __functional/unary_function.h>
150+ # include < __tuple/tuple_indices.h>
150151# include < __type_traits/enable_if.h>
151152# include < __type_traits/integral_constant.h>
152153# include < __type_traits/is_char_like_type.h>
@@ -224,12 +225,66 @@ protected:
224225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator ^=(const __bitset& __v) _NOEXCEPT;
225226
226227 _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 >
227259 _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 ();
229261 }
262+
263+ # ifndef _LIBCPP_CXX03_LANG
230264 _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+ }
232286 }
287+ # endif
233288
234289 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all () const _NOEXCEPT { return !__scan_bits (__bit_not ()); }
235290 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any () const _NOEXCEPT {
@@ -259,10 +314,6 @@ private:
259314 return ~__x;
260315 }
261316 };
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
266317
267318 template <typename _Proj>
268319 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __scan_bits (_Proj __proj) const _NOEXCEPT {
@@ -281,6 +332,10 @@ private:
281332 return false ;
282333 }
283334
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+
284339 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (false_type) const ;
285340 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type) const ;
286341 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __to_ulong (true_type, false_type) const ;
@@ -289,11 +344,11 @@ private:
289344 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type) const ;
290345 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __to_ullong (true_type, false_type) const ;
291346 _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
293348 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
295350 : __first_{static_cast <__storage_type>(__v >> (_Indices * __bits_per_word))...} {}
296- # endif
351+ # endif // _LIBCPP_CXX03_LANG
297352};
298353
299354template <size_t _N_words, size_t _Size>
@@ -325,47 +380,20 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon
325380
326381# endif // _LIBCPP_CXX03_LANG
327382
328- # ifdef _LIBCPP_CXX03_LANG
329383template <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
331394 __init (__v, _BoolConstant<sizeof (unsigned long long ) == sizeof (__storage_type)>());
395+ # endif
332396}
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
369397
370398template <size_t _N_words, size_t _Size>
371399inline _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
402430 *__p ^= (__storage_type (1 ) << __n) - 1 ;
403431}
404432
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-
469433template <size_t _N_words, size_t _Size>
470434inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT {
471435 size_t __h = 0 ;
@@ -524,8 +488,32 @@ protected:
524488
525489 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT;
526490
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
529517
530518 template <bool _Sparse, class _CharT , class _Traits , class _Allocator >
531519 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
@@ -545,19 +533,16 @@ protected:
545533 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any () const _NOEXCEPT;
546534
547535 _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 ;
554536};
555537
556538template <size_t _Size>
557539inline _LIBCPP_CONSTEXPR __bitset<1 , _Size>::__bitset() _NOEXCEPT : __first_(0 ) {}
558540
559541template <size_t _Size>
560542inline _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
561546 : __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v) : static_cast <__storage_type>(__v)) {}
562547
563548template <size_t _Size>
@@ -583,44 +568,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Siz
583568 __first_ ^= ~__storage_type (0 ) >> (__bits_per_word - _Size);
584569}
585570
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-
624571template <size_t _Size>
625572inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<1 , _Size>::all() const _NOEXCEPT {
626573 __storage_type __m = ~__storage_type (0 ) >> (__bits_per_word - _Size);
@@ -683,7 +630,9 @@ protected:
683630 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip () _NOEXCEPT {}
684631
685632 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const { return 0UL ; }
633+ # ifndef _LIBCPP_CXX03_LANG
686634 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const { return 0ULL ; }
635+ # endif
687636
688637 template <bool _Sparse, class _CharT , class _Traits , class _Allocator >
689638 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
@@ -791,8 +740,12 @@ public:
791740 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS (__p < _Size, " bitset::operator[] index out of bounds" );
792741 return __base::__make_ref (__p);
793742 }
794- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const ;
795- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const ;
743+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong () const { return __base::to_ulong (); }
744+ # ifndef _LIBCPP_CXX03_LANG
745+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong () const {
746+ return __base::to_ullong ();
747+ }
748+ # endif
796749 template <class _CharT , class _Traits , class _Allocator >
797750 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
798751 to_string (_CharT __zero = _CharT(' 0' ), _CharT __one = _CharT(' 1' )) const ;
@@ -928,16 +881,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>
928881 return *this ;
929882}
930883
931- template <size_t _Size>
932- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const {
933- return __base::to_ulong ();
934- }
935-
936- template <size_t _Size>
937- inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const {
938- return __base::to_ullong ();
939- }
940-
941884template <size_t _Size>
942885template <class _CharT , class _Traits , class _Allocator >
943886_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
0 commit comments