2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_BITSET
11 #define _LIBCPP_BITSET
31 ~reference() noexcept;
32 reference& operator=(bool x) noexcept; // for b[i] = x;
33 reference& operator=(const reference&) noexcept; // for b[i] = b[j];
34 bool operator~() const noexcept; // flips the bit
35 operator bool() const noexcept; // for x = b[i];
36 reference& flip() noexcept; // for b[i].flip();
39 // 23.3.5.1 constructors:
40 constexpr bitset() noexcept;
41 constexpr bitset(unsigned long long val) noexcept;
42 template <class charT>
43 constexpr explicit bitset(const charT* str,
44 typename basic_string<charT>::size_type n = basic_string<charT>::npos,
45 charT zero = charT('0'), charT one = charT('1')); // until C++26, constexpr since C++23
46 template <class charT>
47 constexpr explicit bitset(const charT* str,
48 typename basic_string_view<charT>::size_type n = basic_string_view<charT>::npos,
49 charT zero = charT('0'), charT one = charT('1')); // since C++26
50 template<class charT, class traits>
52 const basic_string_view<charT,traits>& str,
53 typename basic_string_view<charT,traits>::size_type pos = 0,
54 typename basic_string_view<charT,traits>::size_type n = basic_string_view<charT,traits>::npos,
55 charT zero = charT('0'), charT one = charT('1')); // since C++26
56 template<class charT, class traits, class Allocator>
57 constexpr explicit bitset(
58 const basic_string<charT,traits,Allocator>& str,
59 typename basic_string<charT,traits,Allocator>::size_type pos = 0,
60 typename basic_string<charT,traits,Allocator>::size_type n = basic_string<charT,traits,Allocator>::npos,
61 charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23
63 // 23.3.5.2 bitset operations:
64 bitset& operator&=(const bitset& rhs) noexcept; // constexpr since C++23
65 bitset& operator|=(const bitset& rhs) noexcept; // constexpr since C++23
66 bitset& operator^=(const bitset& rhs) noexcept; // constexpr since C++23
67 bitset& operator<<=(size_t pos) noexcept; // constexpr since C++23
68 bitset& operator>>=(size_t pos) noexcept; // constexpr since C++23
69 bitset& set() noexcept; // constexpr since C++23
70 bitset& set(size_t pos, bool val = true); // constexpr since C++23
71 bitset& reset() noexcept; // constexpr since C++23
72 bitset& reset(size_t pos); // constexpr since C++23
73 bitset operator~() const noexcept; // constexpr since C++23
74 bitset& flip() noexcept; // constexpr since C++23
75 bitset& flip(size_t pos); // constexpr since C++23
78 constexpr bool operator[](size_t pos) const;
79 reference operator[](size_t pos); // constexpr since C++23
80 unsigned long to_ulong() const; // constexpr since C++23
81 unsigned long long to_ullong() const; // constexpr since C++23
82 template <class charT, class traits, class Allocator> // constexpr since C++23
83 basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;
84 template <class charT, class traits> // constexpr since C++23
85 basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
86 template <class charT> // constexpr since C++23
87 basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
88 basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const; // constexpr since C++23
89 size_t count() const noexcept; // constexpr since C++23
90 constexpr size_t size() const noexcept; // constexpr since C++23
91 bool operator==(const bitset& rhs) const noexcept; // constexpr since C++23
92 bool operator!=(const bitset& rhs) const noexcept; // removed in C++20
93 bool test(size_t pos) const; // constexpr since C++23
94 bool all() const noexcept; // constexpr since C++23
95 bool any() const noexcept; // constexpr since C++23
96 bool none() const noexcept; // constexpr since C++23
97 bitset<N> operator<<(size_t pos) const noexcept; // constexpr since C++23
98 bitset<N> operator>>(size_t pos) const noexcept; // constexpr since C++23
101 // 23.3.5.3 bitset operators:
103 bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
106 bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
109 bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
111 template <class charT, class traits, size_t N>
112 basic_istream<charT, traits>&
113 operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
115 template <class charT, class traits, size_t N>
116 basic_ostream<charT, traits>&
117 operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
119 template <size_t N> struct hash<std::bitset<N>>;
125 #include <__algorithm/fill.h>
126 #include <__algorithm/find.h>
127 #include <__assert> // all public C++ headers provide the assertion handler
128 #include <__bit_reference>
130 #include <__functional/hash.h>
131 #include <__functional/unary_function.h>
132 #include <__type_traits/is_char_like_type.h>
136 #include <string_view>
139 // standard-mandated includes
145 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146 # pragma GCC system_header
150 #include <__undef_macros>
153 _LIBCPP_BEGIN_NAMESPACE_STD
155 template <size_t _N_words, size_t _Size>
158 template <size_t _N_words, size_t _Size>
159 struct __has_storage_type<__bitset<_N_words, _Size> >
161 static const bool value = true;
164 template <size_t _N_words, size_t _Size>
168 typedef ptrdiff_t difference_type;
169 typedef size_t size_type;
170 typedef size_type __storage_type;
172 typedef __bitset __self;
173 typedef __storage_type* __storage_pointer;
174 typedef const __storage_type* __const_storage_pointer;
175 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
177 friend class __bit_reference<__bitset>;
178 friend class __bit_const_reference<__bitset>;
179 friend class __bit_iterator<__bitset, false>;
180 friend class __bit_iterator<__bitset, true>;
181 friend struct __bit_array<__bitset>;
183 __storage_type __first_[_N_words];
185 typedef __bit_reference<__bitset> reference;
186 typedef __bit_const_reference<__bitset> const_reference;
187 typedef __bit_iterator<__bitset, false> iterator;
188 typedef __bit_iterator<__bitset, true> const_iterator;
190 _LIBCPP_INLINE_VISIBILITY
191 _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
192 _LIBCPP_INLINE_VISIBILITY
193 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
195 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT
196 {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
197 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
198 {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
199 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT
200 {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
201 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT
202 {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
204 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
205 void operator&=(const __bitset& __v) _NOEXCEPT;
206 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
207 void operator|=(const __bitset& __v) _NOEXCEPT;
208 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
209 void operator^=(const __bitset& __v) _NOEXCEPT;
211 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
212 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const
213 {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());}
214 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const
215 {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());}
217 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
218 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
219 _LIBCPP_INLINE_VISIBILITY
220 size_t __hash_code() const _NOEXCEPT;
222 #ifdef _LIBCPP_CXX03_LANG
223 void __init(unsigned long long __v, false_type) _NOEXCEPT;
224 _LIBCPP_INLINE_VISIBILITY
225 void __init(unsigned long long __v, true_type) _NOEXCEPT;
226 #endif // _LIBCPP_CXX03_LANG
227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
228 unsigned long to_ulong(false_type) const;
229 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
230 unsigned long to_ulong(true_type) const;
231 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
232 unsigned long long to_ullong(false_type) const;
233 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
234 unsigned long long to_ullong(true_type) const;
235 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
236 unsigned long long to_ullong(true_type, false_type) const;
237 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
238 unsigned long long to_ullong(true_type, true_type) const;
241 template <size_t _N_words, size_t _Size>
244 __bitset<_N_words, _Size>::__bitset() _NOEXCEPT
245 #ifndef _LIBCPP_CXX03_LANG
249 #ifdef _LIBCPP_CXX03_LANG
250 _VSTD::fill_n(__first_, _N_words, __storage_type(0));
254 #ifdef _LIBCPP_CXX03_LANG
256 template <size_t _N_words, size_t _Size>
258 __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT
260 __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)];
262 for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word )
263 if ( __sz < __bits_per_word)
264 __t[__i] = static_cast<__storage_type>(__v) & ( 1ULL << __sz ) - 1;
266 __t[__i] = static_cast<__storage_type>(__v);
268 _VSTD::copy(__t, __t + sizeof(__t)/sizeof(__t[0]), __first_);
269 _VSTD::fill(__first_ + sizeof(__t)/sizeof(__t[0]), __first_ + sizeof(__first_)/sizeof(__first_[0]),
273 template <size_t _N_words, size_t _Size>
274 inline _LIBCPP_INLINE_VISIBILITY
276 __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT
279 if (_Size < __bits_per_word)
280 __first_[0] &= ( 1ULL << _Size ) - 1;
282 _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0));
285 #endif // _LIBCPP_CXX03_LANG
287 template <size_t _N_words, size_t _Size>
290 __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
291 #ifndef _LIBCPP_CXX03_LANG
292 #if __SIZEOF_SIZE_T__ == 8
294 #elif __SIZEOF_SIZE_T__ == 4
295 : __first_{static_cast<__storage_type>(__v),
296 _Size >= 2 * __bits_per_word ? static_cast<__storage_type>(__v >> __bits_per_word)
297 : static_cast<__storage_type>((__v >> __bits_per_word) & (__storage_type(1) << (_Size - __bits_per_word)) - 1)}
299 #error This constructor has not been ported to this platform
303 #ifdef _LIBCPP_CXX03_LANG
304 __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>());
308 template <size_t _N_words, size_t _Size>
310 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
311 __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
313 for (size_type __i = 0; __i < _N_words; ++__i)
314 __first_[__i] &= __v.__first_[__i];
317 template <size_t _N_words, size_t _Size>
319 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
320 __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
322 for (size_type __i = 0; __i < _N_words; ++__i)
323 __first_[__i] |= __v.__first_[__i];
326 template <size_t _N_words, size_t _Size>
328 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
329 __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
331 for (size_type __i = 0; __i < _N_words; ++__i)
332 __first_[__i] ^= __v.__first_[__i];
335 template <size_t _N_words, size_t _Size>
336 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
337 __bitset<_N_words, _Size>::flip() _NOEXCEPT
339 // do middle whole words
340 size_type __n = _Size;
341 __storage_pointer __p = __first_;
342 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
344 // do last partial word
347 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
348 __storage_type __b = *__p & __m;
354 template <size_t _N_words, size_t _Size>
355 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
356 __bitset<_N_words, _Size>::to_ulong(false_type) const
358 const_iterator __e = __make_iter(_Size);
359 const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
361 __throw_overflow_error("bitset to_ulong overflow error");
366 template <size_t _N_words, size_t _Size>
368 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
369 __bitset<_N_words, _Size>::to_ulong(true_type) const
374 template <size_t _N_words, size_t _Size>
375 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
376 __bitset<_N_words, _Size>::to_ullong(false_type) const
378 const_iterator __e = __make_iter(_Size);
379 const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
381 __throw_overflow_error("bitset to_ullong overflow error");
383 return to_ullong(true_type());
386 template <size_t _N_words, size_t _Size>
388 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
389 __bitset<_N_words, _Size>::to_ullong(true_type) const
391 return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>());
394 template <size_t _N_words, size_t _Size>
396 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
397 __bitset<_N_words, _Size>::to_ullong(true_type, false_type) const
402 template <size_t _N_words, size_t _Size>
403 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
404 __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
406 unsigned long long __r = __first_[0];
407 for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
408 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
412 template <size_t _N_words, size_t _Size>
413 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
414 __bitset<_N_words, _Size>::all() const _NOEXCEPT
416 // do middle whole words
417 size_type __n = _Size;
418 __const_storage_pointer __p = __first_;
419 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
422 // do last partial word
425 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
432 template <size_t _N_words, size_t _Size>
433 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
434 __bitset<_N_words, _Size>::any() const _NOEXCEPT
436 // do middle whole words
437 size_type __n = _Size;
438 __const_storage_pointer __p = __first_;
439 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
442 // do last partial word
445 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
452 template <size_t _N_words, size_t _Size>
455 __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT
458 for (size_type __i = 0; __i < _N_words; ++__i)
459 __h ^= __first_[__i];
463 template <size_t _Size>
464 class __bitset<1, _Size>
467 typedef ptrdiff_t difference_type;
468 typedef size_t size_type;
469 typedef size_type __storage_type;
471 typedef __bitset __self;
472 typedef __storage_type* __storage_pointer;
473 typedef const __storage_type* __const_storage_pointer;
474 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
476 friend class __bit_reference<__bitset>;
477 friend class __bit_const_reference<__bitset>;
478 friend class __bit_iterator<__bitset, false>;
479 friend class __bit_iterator<__bitset, true>;
480 friend struct __bit_array<__bitset>;
482 __storage_type __first_;
484 typedef __bit_reference<__bitset> reference;
485 typedef __bit_const_reference<__bitset> const_reference;
486 typedef __bit_iterator<__bitset, false> iterator;
487 typedef __bit_iterator<__bitset, true> const_iterator;
489 _LIBCPP_INLINE_VISIBILITY
490 _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
491 _LIBCPP_INLINE_VISIBILITY
492 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
494 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT
495 {return reference(&__first_, __storage_type(1) << __pos);}
496 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
497 {return const_reference(&__first_, __storage_type(1) << __pos);}
498 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT
499 {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
500 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT
501 {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
503 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
504 void operator&=(const __bitset& __v) _NOEXCEPT;
505 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
506 void operator|=(const __bitset& __v) _NOEXCEPT;
507 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
508 void operator^=(const __bitset& __v) _NOEXCEPT;
510 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
511 void flip() _NOEXCEPT;
513 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
514 unsigned long to_ulong() const;
515 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
516 unsigned long long to_ullong() const;
518 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
519 bool all() const _NOEXCEPT;
520 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
521 bool any() const _NOEXCEPT;
523 _LIBCPP_INLINE_VISIBILITY
524 size_t __hash_code() const _NOEXCEPT;
527 template <size_t _Size>
530 __bitset<1, _Size>::__bitset() _NOEXCEPT
535 template <size_t _Size>
538 __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
540 _Size == __bits_per_word ? static_cast<__storage_type>(__v)
541 : static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1)
546 template <size_t _Size>
548 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
549 __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
551 __first_ &= __v.__first_;
554 template <size_t _Size>
556 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
557 __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
559 __first_ |= __v.__first_;
562 template <size_t _Size>
564 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
565 __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
567 __first_ ^= __v.__first_;
570 template <size_t _Size>
572 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
573 __bitset<1, _Size>::flip() _NOEXCEPT
575 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
576 __first_ = ~__first_;
580 template <size_t _Size>
582 _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
583 __bitset<1, _Size>::to_ulong() const
588 template <size_t _Size>
590 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
591 __bitset<1, _Size>::to_ullong() const
596 template <size_t _Size>
598 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
599 __bitset<1, _Size>::all() const _NOEXCEPT
601 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
602 return !(~__first_ & __m);
605 template <size_t _Size>
607 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
608 __bitset<1, _Size>::any() const _NOEXCEPT
610 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
611 return __first_ & __m;
614 template <size_t _Size>
617 __bitset<1, _Size>::__hash_code() const _NOEXCEPT
626 typedef ptrdiff_t difference_type;
627 typedef size_t size_type;
628 typedef size_type __storage_type;
630 typedef __bitset __self;
631 typedef __storage_type* __storage_pointer;
632 typedef const __storage_type* __const_storage_pointer;
633 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
635 friend class __bit_reference<__bitset>;
636 friend class __bit_const_reference<__bitset>;
637 friend class __bit_iterator<__bitset, false>;
638 friend class __bit_iterator<__bitset, true>;
639 friend struct __bit_array<__bitset>;
641 typedef __bit_reference<__bitset> reference;
642 typedef __bit_const_reference<__bitset> const_reference;
643 typedef __bit_iterator<__bitset, false> iterator;
644 typedef __bit_iterator<__bitset, true> const_iterator;
646 _LIBCPP_INLINE_VISIBILITY
647 _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
648 _LIBCPP_INLINE_VISIBILITY
649 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
651 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT
652 {return reference(nullptr, 1);}
653 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
654 {return const_reference(nullptr, 1);}
655 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t) _NOEXCEPT
656 {return iterator(nullptr, 0);}
657 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t) const _NOEXCEPT
658 {return const_iterator(nullptr, 0);}
660 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {}
661 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset&) _NOEXCEPT {}
662 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset&) _NOEXCEPT {}
664 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT {}
666 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {return 0;}
667 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {return 0;}
669 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT {return true;}
670 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT {return false;}
672 _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;}
677 __bitset<0, 0>::__bitset() _NOEXCEPT
683 __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT
687 template <size_t _Size> class _LIBCPP_TEMPLATE_VIS bitset;
688 template <size_t _Size> struct hash<bitset<_Size> >;
690 template <size_t _Size>
691 class _LIBCPP_TEMPLATE_VIS bitset
692 : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size>
695 static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
696 typedef __bitset<__n_words, _Size> base;
699 typedef typename base::reference reference;
700 typedef typename base::const_reference const_reference;
702 // 23.3.5.1 constructors:
703 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
704 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
705 bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
706 template <class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> >
707 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
709 # if _LIBCPP_STD_VER >= 26
710 typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos,
712 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
714 _CharT __zero = _CharT('0'),
715 _CharT __one = _CharT('1')) {
717 size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str));
718 __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one);
720 #if _LIBCPP_STD_VER >= 26
721 template <class _CharT, class _Traits>
722 _LIBCPP_HIDE_FROM_ABI constexpr explicit bitset(
723 basic_string_view<_CharT, _Traits> __str,
724 typename basic_string_view<_CharT, _Traits>::size_type __pos = 0,
725 typename basic_string_view<_CharT, _Traits>::size_type __n = basic_string_view<_CharT, _Traits>::npos,
726 _CharT __zero = _CharT('0'),
727 _CharT __one = _CharT('1')) {
728 if (__pos > __str.size())
729 __throw_out_of_range("bitset string pos out of range");
731 size_t __rlen = std::min(__n, __str.size() - __pos);
732 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);
735 template <class _CharT, class _Traits, class _Allocator>
736 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
737 const basic_string<_CharT, _Traits, _Allocator>& __str,
738 typename basic_string<_CharT, _Traits, _Allocator>::size_type __pos = 0,
739 typename basic_string<_CharT, _Traits, _Allocator>::size_type __n =
740 basic_string<_CharT, _Traits, _Allocator>::npos,
741 _CharT __zero = _CharT('0'),
742 _CharT __one = _CharT('1')) {
743 if (__pos > __str.size())
744 std::__throw_out_of_range("bitset string pos out of range");
746 size_t __rlen = std::min(__n, __str.size() - __pos);
747 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);
750 // 23.3.5.2 bitset operations:
751 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
752 bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
753 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
754 bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
755 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
756 bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
757 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
758 bitset& operator<<=(size_t __pos) _NOEXCEPT;
759 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
760 bitset& operator>>=(size_t __pos) _NOEXCEPT;
761 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
762 bitset& set() _NOEXCEPT;
763 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
764 bitset& set(size_t __pos, bool __val = true);
765 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
766 bitset& reset() _NOEXCEPT;
767 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
768 bitset& reset(size_t __pos);
769 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
770 bitset operator~() const _NOEXCEPT;
771 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
772 bitset& flip() _NOEXCEPT;
773 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
774 bitset& flip(size_t __pos);
777 #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
778 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const {return base::__make_ref(__p);}
780 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
782 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {return base::__make_ref(__p);}
783 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
784 unsigned long to_ulong() const;
785 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
786 unsigned long long to_ullong() const;
787 template <class _CharT, class _Traits, class _Allocator>
788 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
789 basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'),
790 _CharT __one = _CharT('1')) const;
791 template <class _CharT, class _Traits>
792 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
793 basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
794 _CharT __one = _CharT('1')) const;
795 template <class _CharT>
796 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
797 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
798 _CharT __one = _CharT('1')) const;
799 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
800 basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0',
801 char __one = '1') const;
802 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
803 size_t count() const _NOEXCEPT;
804 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;}
805 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
806 bool operator==(const bitset& __rhs) const _NOEXCEPT;
807 #if _LIBCPP_STD_VER <= 17
808 _LIBCPP_INLINE_VISIBILITY
809 bool operator!=(const bitset& __rhs) const _NOEXCEPT;
811 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
812 bool test(size_t __pos) const;
813 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
814 bool all() const _NOEXCEPT;
815 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
816 bool any() const _NOEXCEPT;
817 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT {return !any();}
818 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
819 bitset operator<<(size_t __pos) const _NOEXCEPT;
820 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
821 bitset operator>>(size_t __pos) const _NOEXCEPT;
824 template <class _CharT, class _Traits>
825 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
826 __init_from_string_view(basic_string_view<_CharT, _Traits> __str, _CharT __zero, _CharT __one) {
828 for (size_t __i = 0; __i < __str.size(); ++__i)
829 if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one))
830 std::__throw_invalid_argument("bitset string ctor has invalid argument");
832 size_t __mp = std::min(__str.size(), _Size);
834 for (; __i < __mp; ++__i) {
835 _CharT __c = __str[__mp - 1 - __i];
836 (*this)[__i] = _Traits::eq(__c, __one);
838 std::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
841 _LIBCPP_INLINE_VISIBILITY
842 size_t __hash_code() const _NOEXCEPT {return base::__hash_code();}
844 friend struct hash<bitset>;
847 template <size_t _Size>
849 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
851 bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
853 base::operator&=(__rhs);
857 template <size_t _Size>
859 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
861 bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
863 base::operator|=(__rhs);
867 template <size_t _Size>
869 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
871 bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
873 base::operator^=(__rhs);
877 template <size_t _Size>
878 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
880 bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
882 __pos = _VSTD::min(__pos, _Size);
883 _VSTD::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size));
884 _VSTD::fill_n(base::__make_iter(0), __pos, false);
888 template <size_t _Size>
889 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
891 bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
893 __pos = _VSTD::min(__pos, _Size);
894 _VSTD::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0));
895 _VSTD::fill_n(base::__make_iter(_Size - __pos), __pos, false);
899 template <size_t _Size>
901 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
903 bitset<_Size>::set() _NOEXCEPT
905 _VSTD::fill_n(base::__make_iter(0), _Size, true);
909 template <size_t _Size>
910 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
912 bitset<_Size>::set(size_t __pos, bool __val)
915 __throw_out_of_range("bitset set argument out of range");
917 (*this)[__pos] = __val;
921 template <size_t _Size>
923 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
925 bitset<_Size>::reset() _NOEXCEPT
927 _VSTD::fill_n(base::__make_iter(0), _Size, false);
931 template <size_t _Size>
932 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
934 bitset<_Size>::reset(size_t __pos)
937 __throw_out_of_range("bitset reset argument out of range");
939 (*this)[__pos] = false;
943 template <size_t _Size>
945 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
947 bitset<_Size>::operator~() const _NOEXCEPT
954 template <size_t _Size>
956 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
958 bitset<_Size>::flip() _NOEXCEPT
964 template <size_t _Size>
965 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
967 bitset<_Size>::flip(size_t __pos)
970 __throw_out_of_range("bitset flip argument out of range");
972 reference __r = base::__make_ref(__pos);
977 template <size_t _Size>
979 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
981 bitset<_Size>::to_ulong() const
983 return base::to_ulong();
986 template <size_t _Size>
988 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
990 bitset<_Size>::to_ullong() const
992 return base::to_ullong();
995 template <size_t _Size>
996 template <class _CharT, class _Traits, class _Allocator>
997 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
998 basic_string<_CharT, _Traits, _Allocator>
999 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
1001 basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);
1002 for (size_t __i = 0; __i != _Size; ++__i)
1005 __r[_Size - 1 - __i] = __one;
1010 template <size_t _Size>
1011 template <class _CharT, class _Traits>
1013 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1014 basic_string<_CharT, _Traits, allocator<_CharT> >
1015 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
1017 return to_string<_CharT, _Traits, allocator<_CharT> >(__zero, __one);
1020 template <size_t _Size>
1021 template <class _CharT>
1023 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1024 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
1025 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
1027 return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(__zero, __one);
1030 template <size_t _Size>
1032 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1033 basic_string<char, char_traits<char>, allocator<char> >
1034 bitset<_Size>::to_string(char __zero, char __one) const
1036 return to_string<char, char_traits<char>, allocator<char> >(__zero, __one);
1039 template <size_t _Size>
1041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1043 bitset<_Size>::count() const _NOEXCEPT
1045 return static_cast<size_t>(_VSTD::__count_bool<true>(base::__make_iter(0), _Size));
1048 template <size_t _Size>
1050 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1052 bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
1054 return _VSTD::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0));
1057 #if _LIBCPP_STD_VER <= 17
1059 template <size_t _Size>
1061 _LIBCPP_HIDE_FROM_ABI
1063 bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
1065 return !(*this == __rhs);
1070 template <size_t _Size>
1071 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1073 bitset<_Size>::test(size_t __pos) const
1076 __throw_out_of_range("bitset test argument out of range");
1078 return (*this)[__pos];
1081 template <size_t _Size>
1083 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1085 bitset<_Size>::all() const _NOEXCEPT
1090 template <size_t _Size>
1092 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1094 bitset<_Size>::any() const _NOEXCEPT
1099 template <size_t _Size>
1101 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1103 bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
1110 template <size_t _Size>
1112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1114 bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
1121 template <size_t _Size>
1122 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
1124 operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
1126 bitset<_Size> __r = __x;
1131 template <size_t _Size>
1132 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
1134 operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
1136 bitset<_Size> __r = __x;
1141 template <size_t _Size>
1142 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
1144 operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
1146 bitset<_Size> __r = __x;
1151 template <size_t _Size>
1152 struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
1153 : public __unary_function<bitset<_Size>, size_t>
1155 _LIBCPP_INLINE_VISIBILITY
1156 size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT
1157 {return __bs.__hash_code();}
1160 template <class _CharT, class _Traits, size_t _Size>
1161 _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1162 operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x);
1164 template <class _CharT, class _Traits, size_t _Size>
1165 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
1166 operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);
1168 _LIBCPP_END_NAMESPACE_STD
1172 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1173 # include <concepts>
1175 # include <type_traits>
1178 #endif // _LIBCPP_BITSET