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
33 ~reference() noexcept;
34 reference& operator=(bool x) noexcept; // for b[i] = x;
35 reference& operator=(const reference&) noexcept; // for b[i] = b[j];
36 bool operator~() const noexcept; // flips the bit
37 operator bool() const noexcept; // for x = b[i];
38 reference& flip() noexcept; // for b[i].flip();
41 // 23.3.5.1 constructors:
42 constexpr bitset() noexcept;
43 constexpr bitset(unsigned long long val) noexcept;
44 template <class charT>
45 constexpr explicit bitset(const charT* str,
46 typename basic_string<charT>::size_type n = basic_string<charT>::npos,
47 charT zero = charT('0'), charT one = charT('1')); // until C++26, constexpr since C++23
48 template <class charT>
49 constexpr explicit bitset(const charT* str,
50 typename basic_string_view<charT>::size_type n = basic_string_view<charT>::npos,
51 charT zero = charT('0'), charT one = charT('1')); // since C++26
52 template<class charT, class traits>
54 const basic_string_view<charT,traits>& str,
55 typename basic_string_view<charT,traits>::size_type pos = 0,
56 typename basic_string_view<charT,traits>::size_type n = basic_string_view<charT,traits>::npos,
57 charT zero = charT('0'), charT one = charT('1')); // since C++26
58 template<class charT, class traits, class Allocator>
59 constexpr explicit bitset(
60 const basic_string<charT,traits,Allocator>& str,
61 typename basic_string<charT,traits,Allocator>::size_type pos = 0,
62 typename basic_string<charT,traits,Allocator>::size_type n = basic_string<charT,traits,Allocator>::npos,
63 charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23
65 // 23.3.5.2 bitset operations:
66 bitset& operator&=(const bitset& rhs) noexcept; // constexpr since C++23
67 bitset& operator|=(const bitset& rhs) noexcept; // constexpr since C++23
68 bitset& operator^=(const bitset& rhs) noexcept; // constexpr since C++23
69 bitset& operator<<=(size_t pos) noexcept; // constexpr since C++23
70 bitset& operator>>=(size_t pos) noexcept; // constexpr since C++23
71 bitset& set() noexcept; // constexpr since C++23
72 bitset& set(size_t pos, bool val = true); // constexpr since C++23
73 bitset& reset() noexcept; // constexpr since C++23
74 bitset& reset(size_t pos); // constexpr since C++23
75 bitset operator~() const noexcept; // constexpr since C++23
76 bitset& flip() noexcept; // constexpr since C++23
77 bitset& flip(size_t pos); // constexpr since C++23
80 constexpr bool operator[](size_t pos) const;
81 reference operator[](size_t pos); // constexpr since C++23
82 unsigned long to_ulong() const; // constexpr since C++23
83 unsigned long long to_ullong() const; // constexpr since C++23
84 template <class charT, class traits, class Allocator> // constexpr since C++23
85 basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;
86 template <class charT, class traits> // constexpr since C++23
87 basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
88 template <class charT> // constexpr since C++23
89 basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
90 basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const; // constexpr since C++23
91 size_t count() const noexcept; // constexpr since C++23
92 constexpr size_t size() const noexcept; // constexpr since C++23
93 bool operator==(const bitset& rhs) const noexcept; // constexpr since C++23
94 bool operator!=(const bitset& rhs) const noexcept; // removed in C++20
95 bool test(size_t pos) const; // constexpr since C++23
96 bool all() const noexcept; // constexpr since C++23
97 bool any() const noexcept; // constexpr since C++23
98 bool none() const noexcept; // constexpr since C++23
99 bitset<N> operator<<(size_t pos) const noexcept; // constexpr since C++23
100 bitset<N> operator>>(size_t pos) const noexcept; // constexpr since C++23
103 // 23.3.5.3 bitset operators:
105 bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
108 bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
111 bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
113 template <class charT, class traits, size_t N>
114 basic_istream<charT, traits>&
115 operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
117 template <class charT, class traits, size_t N>
118 basic_ostream<charT, traits>&
119 operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
121 template <size_t N> struct hash<std::bitset<N>>;
129 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
130 # include <__cxx03/bitset>
132 # include <__algorithm/count.h>
133 # include <__algorithm/fill.h>
134 # include <__algorithm/fill_n.h>
135 # include <__algorithm/find.h>
137 # include <__bit_reference>
139 # include <__functional/hash.h>
140 # include <__functional/unary_function.h>
141 # include <__type_traits/is_char_like_type.h>
143 # include <stdexcept>
144 # include <string_view>
147 // standard-mandated includes
153 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
154 # pragma GCC system_header
158 # include <__undef_macros>
160 _LIBCPP_BEGIN_NAMESPACE_STD
162 template <size_t _N_words, size_t _Size>
165 template <size_t _N_words, size_t _Size>
166 struct __has_storage_type<__bitset<_N_words, _Size> > {
167 static const bool value = true;
170 template <size_t _N_words, size_t _Size>
173 typedef ptrdiff_t difference_type;
174 typedef size_t size_type;
175 typedef size_type __storage_type;
178 typedef __bitset __self;
179 typedef __storage_type* __storage_pointer;
180 typedef const __storage_type* __const_storage_pointer;
181 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
183 friend class __bit_reference<__bitset>;
184 friend class __bit_const_reference<__bitset>;
185 friend class __bit_iterator<__bitset, false>;
186 friend class __bit_iterator<__bitset, true>;
187 friend struct __bit_array<__bitset>;
189 __storage_type __first_[_N_words];
191 typedef __bit_reference<__bitset> reference;
192 typedef __bit_const_reference<__bitset> const_reference;
193 typedef __bit_iterator<__bitset, false> __iterator;
194 typedef __bit_iterator<__bitset, true> __const_iterator;
196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
197 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
199 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {
200 return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
202 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {
203 return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT {
206 return __iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT {
209 return __const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
212 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;
213 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset& __v) _NOEXCEPT;
214 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT;
216 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
217 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {
218 return to_ulong(integral_constant < bool, _Size< sizeof(unsigned long) * CHAR_BIT>());
220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {
221 return to_ullong(integral_constant < bool, _Size< sizeof(unsigned long long) * CHAR_BIT>());
224 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
226 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;
229 # ifdef _LIBCPP_CXX03_LANG
230 void __init(unsigned long long __v, false_type) _NOEXCEPT;
231 _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT;
232 # endif // _LIBCPP_CXX03_LANG
233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(false_type) const;
234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(true_type) const;
235 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(false_type) const;
236 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type) const;
237 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type, false_type) const;
238 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type, true_type) const;
241 template <size_t _N_words, size_t _Size>
242 inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT
243 # ifndef _LIBCPP_CXX03_LANG
247 # ifdef _LIBCPP_CXX03_LANG
248 std::fill_n(__first_, _N_words, __storage_type(0));
252 # ifdef _LIBCPP_CXX03_LANG
254 template <size_t _N_words, size_t _Size>
255 void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT {
256 __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)];
258 for (size_t __i = 0; __i < sizeof(__t) / sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word)
259 if (__sz < __bits_per_word)
260 __t[__i] = static_cast<__storage_type>(__v) & (1ULL << __sz) - 1;
262 __t[__i] = static_cast<__storage_type>(__v);
264 std::copy(__t, __t + sizeof(__t) / sizeof(__t[0]), __first_);
266 __first_ + sizeof(__t) / sizeof(__t[0]), __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0));
269 template <size_t _N_words, size_t _Size>
270 inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT {
272 if (_Size < __bits_per_word)
273 __first_[0] &= (1ULL << _Size) - 1;
275 std::fill(__first_ + 1, __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0));
278 # endif // _LIBCPP_CXX03_LANG
280 template <size_t _N_words, size_t _Size>
281 inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
282 # ifndef _LIBCPP_CXX03_LANG
283 # if __SIZEOF_SIZE_T__ == 8
285 # elif __SIZEOF_SIZE_T__ == 4
286 : __first_{static_cast<__storage_type>(__v),
287 _Size >= 2 * __bits_per_word
288 ? static_cast<__storage_type>(__v >> __bits_per_word)
289 : static_cast<__storage_type>((__v >> __bits_per_word) &
290 (__storage_type(1) << (_Size - __bits_per_word)) - 1)}
292 # error This constructor has not been ported to this platform
296 # ifdef _LIBCPP_CXX03_LANG
297 __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>());
301 template <size_t _N_words, size_t _Size>
302 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
303 __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT {
304 for (size_type __i = 0; __i < _N_words; ++__i)
305 __first_[__i] &= __v.__first_[__i];
308 template <size_t _N_words, size_t _Size>
309 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
310 __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT {
311 for (size_type __i = 0; __i < _N_words; ++__i)
312 __first_[__i] |= __v.__first_[__i];
315 template <size_t _N_words, size_t _Size>
316 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
317 __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {
318 for (size_type __i = 0; __i < _N_words; ++__i)
319 __first_[__i] ^= __v.__first_[__i];
322 template <size_t _N_words, size_t _Size>
323 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Size>::flip() _NOEXCEPT {
324 // do middle whole words
325 size_type __n = _Size;
326 __storage_pointer __p = __first_;
327 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
329 // do last partial word
331 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
332 __storage_type __b = *__p & __m;
338 template <size_t _N_words, size_t _Size>
339 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
340 __bitset<_N_words, _Size>::to_ulong(false_type) const {
341 __const_iterator __e = __make_iter(_Size);
342 __const_iterator __i = std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
344 __throw_overflow_error("bitset to_ulong overflow error");
349 template <size_t _N_words, size_t _Size>
350 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
351 __bitset<_N_words, _Size>::to_ulong(true_type) const {
355 template <size_t _N_words, size_t _Size>
356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
357 __bitset<_N_words, _Size>::to_ullong(false_type) const {
358 __const_iterator __e = __make_iter(_Size);
359 __const_iterator __i = std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
361 __throw_overflow_error("bitset to_ullong overflow error");
363 return to_ullong(true_type());
366 template <size_t _N_words, size_t _Size>
367 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
368 __bitset<_N_words, _Size>::to_ullong(true_type) const {
369 return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>());
372 template <size_t _N_words, size_t _Size>
373 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
374 __bitset<_N_words, _Size>::to_ullong(true_type, false_type) const {
378 template <size_t _N_words, size_t _Size>
379 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
380 __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
381 unsigned long long __r = __first_[0];
382 _LIBCPP_DIAGNOSTIC_PUSH
383 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
384 for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
385 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
386 _LIBCPP_DIAGNOSTIC_POP
390 template <size_t _N_words, size_t _Size>
391 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::all() const _NOEXCEPT {
392 // do middle whole words
393 size_type __n = _Size;
394 __const_storage_pointer __p = __first_;
395 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
398 // do last partial word
400 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
407 template <size_t _N_words, size_t _Size>
408 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::any() const _NOEXCEPT {
409 // do middle whole words
410 size_type __n = _Size;
411 __const_storage_pointer __p = __first_;
412 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
415 // do last partial word
417 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
424 template <size_t _N_words, size_t _Size>
425 inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT {
427 for (size_type __i = 0; __i < _N_words; ++__i)
428 __h ^= __first_[__i];
432 template <size_t _Size>
433 class __bitset<1, _Size> {
435 typedef ptrdiff_t difference_type;
436 typedef size_t size_type;
437 typedef size_type __storage_type;
440 typedef __bitset __self;
441 typedef __storage_type* __storage_pointer;
442 typedef const __storage_type* __const_storage_pointer;
443 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
445 friend class __bit_reference<__bitset>;
446 friend class __bit_const_reference<__bitset>;
447 friend class __bit_iterator<__bitset, false>;
448 friend class __bit_iterator<__bitset, true>;
449 friend struct __bit_array<__bitset>;
451 __storage_type __first_;
453 typedef __bit_reference<__bitset> reference;
454 typedef __bit_const_reference<__bitset> const_reference;
455 typedef __bit_iterator<__bitset, false> __iterator;
456 typedef __bit_iterator<__bitset, true> __const_iterator;
458 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
459 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
461 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {
462 return reference(&__first_, __storage_type(1) << __pos);
464 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {
465 return const_reference(&__first_, __storage_type(1) << __pos);
467 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT {
468 return __iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
470 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT {
471 return __const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
474 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;
475 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset& __v) _NOEXCEPT;
476 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT;
478 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
480 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;
481 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;
483 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
484 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
486 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;
489 template <size_t _Size>
490 inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0) {}
492 template <size_t _Size>
493 inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
494 : __first_(_Size == __bits_per_word ? static_cast<__storage_type>(__v)
495 : static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1)) {}
497 template <size_t _Size>
498 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
499 __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT {
500 __first_ &= __v.__first_;
503 template <size_t _Size>
504 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
505 __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT {
506 __first_ |= __v.__first_;
509 template <size_t _Size>
510 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
511 __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {
512 __first_ ^= __v.__first_;
515 template <size_t _Size>
516 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Size>::flip() _NOEXCEPT {
517 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
518 __first_ = ~__first_;
522 template <size_t _Size>
523 inline _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1, _Size>::to_ulong() const {
527 template <size_t _Size>
528 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __bitset<1, _Size>::to_ullong() const {
532 template <size_t _Size>
533 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<1, _Size>::all() const _NOEXCEPT {
534 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
535 return !(~__first_ & __m);
538 template <size_t _Size>
539 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<1, _Size>::any() const _NOEXCEPT {
540 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
541 return __first_ & __m;
544 template <size_t _Size>
545 inline size_t __bitset<1, _Size>::__hash_code() const _NOEXCEPT {
550 class __bitset<0, 0> {
552 typedef ptrdiff_t difference_type;
553 typedef size_t size_type;
554 typedef size_type __storage_type;
557 typedef __bitset __self;
558 typedef __storage_type* __storage_pointer;
559 typedef const __storage_type* __const_storage_pointer;
560 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
562 friend class __bit_reference<__bitset>;
563 friend class __bit_const_reference<__bitset>;
564 friend class __bit_iterator<__bitset, false>;
565 friend class __bit_iterator<__bitset, true>;
566 friend struct __bit_array<__bitset>;
568 typedef __bit_reference<__bitset> reference;
569 typedef __bit_const_reference<__bitset> const_reference;
570 typedef __bit_iterator<__bitset, false> __iterator;
571 typedef __bit_iterator<__bitset, true> __const_iterator;
573 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
574 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
576 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT {
577 return reference(nullptr, 1);
579 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT {
580 return const_reference(nullptr, 1);
582 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t) _NOEXCEPT {
583 return __iterator(nullptr, 0);
585 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t) const _NOEXCEPT {
586 return __const_iterator(nullptr, 0);
589 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {}
590 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset&) _NOEXCEPT {}
591 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset&) _NOEXCEPT {}
593 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT {}
595 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return 0; }
596 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { return 0; }
598 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return true; }
599 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return false; }
601 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return 0; }
604 inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT {}
606 inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT {}
608 template <size_t _Size>
609 class _LIBCPP_TEMPLATE_VIS bitset;
610 template <size_t _Size>
611 struct hash<bitset<_Size> >;
613 template <size_t _Size>
614 class _LIBCPP_TEMPLATE_VIS bitset
615 : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> {
617 static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
618 typedef __bitset<__n_words, _Size> __base;
621 typedef typename __base::reference reference;
622 typedef typename __base::const_reference const_reference;
624 // 23.3.5.1 constructors:
625 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
626 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : __base(__v) {}
627 template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0>
628 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
630 # if _LIBCPP_STD_VER >= 26
631 typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos,
633 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
635 _CharT __zero = _CharT('0'),
636 _CharT __one = _CharT('1')) {
638 size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str));
639 __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one);
641 # if _LIBCPP_STD_VER >= 26
642 template <class _CharT, class _Traits>
643 _LIBCPP_HIDE_FROM_ABI constexpr explicit bitset(
644 basic_string_view<_CharT, _Traits> __str,
645 typename basic_string_view<_CharT, _Traits>::size_type __pos = 0,
646 typename basic_string_view<_CharT, _Traits>::size_type __n = basic_string_view<_CharT, _Traits>::npos,
647 _CharT __zero = _CharT('0'),
648 _CharT __one = _CharT('1')) {
649 if (__pos > __str.size())
650 __throw_out_of_range("bitset string pos out of range");
652 size_t __rlen = std::min(__n, __str.size() - __pos);
653 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);
656 template <class _CharT, class _Traits, class _Allocator>
657 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
658 const basic_string<_CharT, _Traits, _Allocator>& __str,
659 typename basic_string<_CharT, _Traits, _Allocator>::size_type __pos = 0,
660 typename basic_string<_CharT, _Traits, _Allocator>::size_type __n =
661 basic_string<_CharT, _Traits, _Allocator>::npos,
662 _CharT __zero = _CharT('0'),
663 _CharT __one = _CharT('1')) {
664 if (__pos > __str.size())
665 std::__throw_out_of_range("bitset string pos out of range");
667 size_t __rlen = std::min(__n, __str.size() - __pos);
668 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);
671 // 23.3.5.2 bitset operations:
672 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
673 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
674 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
675 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator<<=(size_t __pos) _NOEXCEPT;
676 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator>>=(size_t __pos) _NOEXCEPT;
677 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& set() _NOEXCEPT;
678 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& set(size_t __pos, bool __val = true);
679 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& reset() _NOEXCEPT;
680 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& reset(size_t __pos);
681 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator~() const _NOEXCEPT;
682 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip() _NOEXCEPT;
683 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip(size_t __pos);
686 # ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
687 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const {
688 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds");
689 return __base::__make_ref(__p);
692 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {
693 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds");
694 return __base::__make_ref(__p);
697 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {
698 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds");
699 return __base::__make_ref(__p);
701 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;
702 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;
703 template <class _CharT, class _Traits, class _Allocator>
704 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
705 to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;
706 template <class _CharT, class _Traits>
707 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, allocator<_CharT> >
708 to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;
709 template <class _CharT>
710 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
711 to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;
712 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<char, char_traits<char>, allocator<char> >
713 to_string(char __zero = '0', char __one = '1') const;
714 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t count() const _NOEXCEPT;
715 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT { return _Size; }
716 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT;
717 # if _LIBCPP_STD_VER <= 17
718 _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT;
720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const;
721 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
722 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
723 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT { return !any(); }
724 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT;
725 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT;
728 template <class _CharT, class _Traits>
729 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
730 __init_from_string_view(basic_string_view<_CharT, _Traits> __str, _CharT __zero, _CharT __one) {
731 for (size_t __i = 0; __i < __str.size(); ++__i)
732 if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one))
733 std::__throw_invalid_argument("bitset string ctor has invalid argument");
735 size_t __mp = std::min(__str.size(), _Size);
737 for (; __i < __mp; ++__i) {
738 _CharT __c = __str[__mp - 1 - __i];
739 (*this)[__i] = _Traits::eq(__c, __one);
741 std::fill(__base::__make_iter(__i), __base::__make_iter(_Size), false);
744 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); }
746 friend struct hash<bitset>;
749 template <size_t _Size>
750 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
751 bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT {
752 __base::operator&=(__rhs);
756 template <size_t _Size>
757 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
758 bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT {
759 __base::operator|=(__rhs);
763 template <size_t _Size>
764 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
765 bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT {
766 __base::operator^=(__rhs);
770 template <size_t _Size>
771 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT {
772 __pos = std::min(__pos, _Size);
773 std::copy_backward(__base::__make_iter(0), __base::__make_iter(_Size - __pos), __base::__make_iter(_Size));
774 std::fill_n(__base::__make_iter(0), __pos, false);
778 template <size_t _Size>
779 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT {
780 __pos = std::min(__pos, _Size);
781 std::copy(__base::__make_iter(__pos), __base::__make_iter(_Size), __base::__make_iter(0));
782 std::fill_n(__base::__make_iter(_Size - __pos), __pos, false);
786 template <size_t _Size>
787 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set() _NOEXCEPT {
788 std::fill_n(__base::__make_iter(0), _Size, true);
792 template <size_t _Size>
793 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set(size_t __pos, bool __val) {
795 __throw_out_of_range("bitset set argument out of range");
797 (*this)[__pos] = __val;
801 template <size_t _Size>
802 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT {
803 std::fill_n(__base::__make_iter(0), _Size, false);
807 template <size_t _Size>
808 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset(size_t __pos) {
810 __throw_out_of_range("bitset reset argument out of range");
812 (*this)[__pos] = false;
816 template <size_t _Size>
817 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> bitset<_Size>::operator~() const _NOEXCEPT {
823 template <size_t _Size>
824 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT {
829 template <size_t _Size>
830 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip(size_t __pos) {
832 __throw_out_of_range("bitset flip argument out of range");
834 reference __r = __base::__make_ref(__pos);
839 template <size_t _Size>
840 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const {
841 return __base::to_ulong();
844 template <size_t _Size>
845 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const {
846 return __base::to_ullong();
849 template <size_t _Size>
850 template <class _CharT, class _Traits, class _Allocator>
851 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
852 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const {
853 basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);
854 for (size_t __i = 0; __i != _Size; ++__i) {
856 __r[_Size - 1 - __i] = __one;
861 template <size_t _Size>
862 template <class _CharT, class _Traits>
863 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, allocator<_CharT> >
864 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const {
865 return to_string<_CharT, _Traits, allocator<_CharT> >(__zero, __one);
868 template <size_t _Size>
869 template <class _CharT>
870 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
871 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const {
872 return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(__zero, __one);
875 template <size_t _Size>
876 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<char, char_traits<char>, allocator<char> >
877 bitset<_Size>::to_string(char __zero, char __one) const {
878 return to_string<char, char_traits<char>, allocator<char> >(__zero, __one);
881 template <size_t _Size>
882 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT {
883 return static_cast<size_t>(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true));
886 template <size_t _Size>
887 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
888 bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT {
889 return std::equal(__base::__make_iter(0), __base::__make_iter(_Size), __rhs.__make_iter(0));
892 # if _LIBCPP_STD_VER <= 17
894 template <size_t _Size>
895 inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT {
896 return !(*this == __rhs);
901 template <size_t _Size>
902 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const {
904 __throw_out_of_range("bitset test argument out of range");
906 return (*this)[__pos];
909 template <size_t _Size>
910 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::all() const _NOEXCEPT {
911 return __base::all();
914 template <size_t _Size>
915 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::any() const _NOEXCEPT {
916 return __base::any();
919 template <size_t _Size>
920 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
921 bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT {
927 template <size_t _Size>
928 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
929 bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT {
935 template <size_t _Size>
936 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
937 operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
938 bitset<_Size> __r = __x;
943 template <size_t _Size>
944 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
945 operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
946 bitset<_Size> __r = __x;
951 template <size_t _Size>
952 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
953 operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
954 bitset<_Size> __r = __x;
959 template <size_t _Size>
960 struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> > : public __unary_function<bitset<_Size>, size_t> {
961 _LIBCPP_HIDE_FROM_ABI size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT { return __bs.__hash_code(); }
964 template <class _CharT, class _Traits, size_t _Size>
965 _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
966 operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x);
968 template <class _CharT, class _Traits, size_t _Size>
969 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
970 operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);
972 _LIBCPP_END_NAMESPACE_STD
976 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
979 # include <type_traits>
981 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
983 #endif // _LIBCPP_BITSET