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 #include <__algorithm/count.h>
130 #include <__algorithm/fill.h>
131 #include <__algorithm/fill_n.h>
132 #include <__algorithm/find.h>
133 #include <__bit_reference>
135 #include <__functional/hash.h>
136 #include <__functional/unary_function.h>
137 #include <__type_traits/is_char_like_type.h>
140 #include <string_view>
143 // standard-mandated includes
149 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
150 # pragma GCC system_header
154 #include <__undef_macros>
156 _LIBCPP_BEGIN_NAMESPACE_STD
158 template <size_t _N_words, size_t _Size>
161 template <size_t _N_words, size_t _Size>
162 struct __has_storage_type<__bitset<_N_words, _Size> > {
163 static const bool value = true;
166 template <size_t _N_words, size_t _Size>
169 typedef ptrdiff_t difference_type;
170 typedef size_t size_type;
171 typedef size_type __storage_type;
174 typedef __bitset __self;
175 typedef __storage_type* __storage_pointer;
176 typedef const __storage_type* __const_storage_pointer;
177 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
179 friend class __bit_reference<__bitset>;
180 friend class __bit_const_reference<__bitset>;
181 friend class __bit_iterator<__bitset, false>;
182 friend class __bit_iterator<__bitset, true>;
183 friend struct __bit_array<__bitset>;
185 __storage_type __first_[_N_words];
187 typedef __bit_reference<__bitset> reference;
188 typedef __bit_const_reference<__bitset> const_reference;
189 typedef __bit_iterator<__bitset, false> __iterator;
190 typedef __bit_iterator<__bitset, true> __const_iterator;
192 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
193 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
195 _LIBCPP_HIDE_FROM_ABI _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);
198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {
199 return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);
201 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT {
202 return __iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT {
205 return __const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;
209 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset& __v) _NOEXCEPT;
210 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT;
212 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
213 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {
214 return to_ulong(integral_constant < bool, _Size< sizeof(unsigned long) * CHAR_BIT>());
216 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {
217 return to_ullong(integral_constant < bool, _Size< sizeof(unsigned long long) * CHAR_BIT>());
220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
221 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
222 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;
225 #ifdef _LIBCPP_CXX03_LANG
226 void __init(unsigned long long __v, false_type) _NOEXCEPT;
227 _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT;
228 #endif // _LIBCPP_CXX03_LANG
229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(false_type) const;
230 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(true_type) const;
231 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(false_type) const;
232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type) const;
233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type, false_type) const;
234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type, true_type) const;
237 template <size_t _N_words, size_t _Size>
238 inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT
239 #ifndef _LIBCPP_CXX03_LANG
243 #ifdef _LIBCPP_CXX03_LANG
244 std::fill_n(__first_, _N_words, __storage_type(0));
248 #ifdef _LIBCPP_CXX03_LANG
250 template <size_t _N_words, size_t _Size>
251 void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT {
252 __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)];
254 for (size_t __i = 0; __i < sizeof(__t) / sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word)
255 if (__sz < __bits_per_word)
256 __t[__i] = static_cast<__storage_type>(__v) & (1ULL << __sz) - 1;
258 __t[__i] = static_cast<__storage_type>(__v);
260 std::copy(__t, __t + sizeof(__t) / sizeof(__t[0]), __first_);
262 __first_ + sizeof(__t) / sizeof(__t[0]), __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0));
265 template <size_t _N_words, size_t _Size>
266 inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT {
268 if (_Size < __bits_per_word)
269 __first_[0] &= (1ULL << _Size) - 1;
271 std::fill(__first_ + 1, __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0));
274 #endif // _LIBCPP_CXX03_LANG
276 template <size_t _N_words, size_t _Size>
277 inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
278 #ifndef _LIBCPP_CXX03_LANG
279 # if __SIZEOF_SIZE_T__ == 8
281 # elif __SIZEOF_SIZE_T__ == 4
282 : __first_{static_cast<__storage_type>(__v),
283 _Size >= 2 * __bits_per_word
284 ? static_cast<__storage_type>(__v >> __bits_per_word)
285 : static_cast<__storage_type>((__v >> __bits_per_word) &
286 (__storage_type(1) << (_Size - __bits_per_word)) - 1)}
288 # error This constructor has not been ported to this platform
292 #ifdef _LIBCPP_CXX03_LANG
293 __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>());
297 template <size_t _N_words, size_t _Size>
298 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
299 __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT {
300 for (size_type __i = 0; __i < _N_words; ++__i)
301 __first_[__i] &= __v.__first_[__i];
304 template <size_t _N_words, size_t _Size>
305 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
306 __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT {
307 for (size_type __i = 0; __i < _N_words; ++__i)
308 __first_[__i] |= __v.__first_[__i];
311 template <size_t _N_words, size_t _Size>
312 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
313 __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {
314 for (size_type __i = 0; __i < _N_words; ++__i)
315 __first_[__i] ^= __v.__first_[__i];
318 template <size_t _N_words, size_t _Size>
319 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Size>::flip() _NOEXCEPT {
320 // do middle whole words
321 size_type __n = _Size;
322 __storage_pointer __p = __first_;
323 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
325 // do last partial word
327 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
328 __storage_type __b = *__p & __m;
334 template <size_t _N_words, size_t _Size>
335 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
336 __bitset<_N_words, _Size>::to_ulong(false_type) const {
337 __const_iterator __e = __make_iter(_Size);
338 __const_iterator __i = std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
340 __throw_overflow_error("bitset to_ulong overflow error");
345 template <size_t _N_words, size_t _Size>
346 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
347 __bitset<_N_words, _Size>::to_ulong(true_type) const {
351 template <size_t _N_words, size_t _Size>
352 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
353 __bitset<_N_words, _Size>::to_ullong(false_type) const {
354 __const_iterator __e = __make_iter(_Size);
355 __const_iterator __i = std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
357 __throw_overflow_error("bitset to_ullong overflow error");
359 return to_ullong(true_type());
362 template <size_t _N_words, size_t _Size>
363 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
364 __bitset<_N_words, _Size>::to_ullong(true_type) const {
365 return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>());
368 template <size_t _N_words, size_t _Size>
369 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
370 __bitset<_N_words, _Size>::to_ullong(true_type, false_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(true_type, true_type) const {
377 unsigned long long __r = __first_[0];
378 _LIBCPP_DIAGNOSTIC_PUSH
379 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
380 for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
381 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
382 _LIBCPP_DIAGNOSTIC_POP
386 template <size_t _N_words, size_t _Size>
387 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::all() const _NOEXCEPT {
388 // do middle whole words
389 size_type __n = _Size;
390 __const_storage_pointer __p = __first_;
391 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
394 // do last partial word
396 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
403 template <size_t _N_words, size_t _Size>
404 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::any() const _NOEXCEPT {
405 // do middle whole words
406 size_type __n = _Size;
407 __const_storage_pointer __p = __first_;
408 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
411 // do last partial word
413 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
420 template <size_t _N_words, size_t _Size>
421 inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT {
423 for (size_type __i = 0; __i < _N_words; ++__i)
424 __h ^= __first_[__i];
428 template <size_t _Size>
429 class __bitset<1, _Size> {
431 typedef ptrdiff_t difference_type;
432 typedef size_t size_type;
433 typedef size_type __storage_type;
436 typedef __bitset __self;
437 typedef __storage_type* __storage_pointer;
438 typedef const __storage_type* __const_storage_pointer;
439 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
441 friend class __bit_reference<__bitset>;
442 friend class __bit_const_reference<__bitset>;
443 friend class __bit_iterator<__bitset, false>;
444 friend class __bit_iterator<__bitset, true>;
445 friend struct __bit_array<__bitset>;
447 __storage_type __first_;
449 typedef __bit_reference<__bitset> reference;
450 typedef __bit_const_reference<__bitset> const_reference;
451 typedef __bit_iterator<__bitset, false> __iterator;
452 typedef __bit_iterator<__bitset, true> __const_iterator;
454 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
455 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
457 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT {
458 return reference(&__first_, __storage_type(1) << __pos);
460 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {
461 return const_reference(&__first_, __storage_type(1) << __pos);
463 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT {
464 return __iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
466 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT {
467 return __const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);
470 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;
471 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset& __v) _NOEXCEPT;
472 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT;
474 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
476 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;
477 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;
479 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
480 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
482 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;
485 template <size_t _Size>
486 inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0) {}
488 template <size_t _Size>
489 inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
490 : __first_(_Size == __bits_per_word ? static_cast<__storage_type>(__v)
491 : static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1)) {}
493 template <size_t _Size>
494 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
495 __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT {
496 __first_ &= __v.__first_;
499 template <size_t _Size>
500 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
501 __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT {
502 __first_ |= __v.__first_;
505 template <size_t _Size>
506 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
507 __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {
508 __first_ ^= __v.__first_;
511 template <size_t _Size>
512 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Size>::flip() _NOEXCEPT {
513 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
514 __first_ = ~__first_;
518 template <size_t _Size>
519 inline _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1, _Size>::to_ulong() const {
523 template <size_t _Size>
524 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __bitset<1, _Size>::to_ullong() const {
528 template <size_t _Size>
529 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<1, _Size>::all() const _NOEXCEPT {
530 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
531 return !(~__first_ & __m);
534 template <size_t _Size>
535 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<1, _Size>::any() const _NOEXCEPT {
536 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
537 return __first_ & __m;
540 template <size_t _Size>
541 inline size_t __bitset<1, _Size>::__hash_code() const _NOEXCEPT {
546 class __bitset<0, 0> {
548 typedef ptrdiff_t difference_type;
549 typedef size_t size_type;
550 typedef size_type __storage_type;
553 typedef __bitset __self;
554 typedef __storage_type* __storage_pointer;
555 typedef const __storage_type* __const_storage_pointer;
556 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
558 friend class __bit_reference<__bitset>;
559 friend class __bit_const_reference<__bitset>;
560 friend class __bit_iterator<__bitset, false>;
561 friend class __bit_iterator<__bitset, true>;
562 friend struct __bit_array<__bitset>;
564 typedef __bit_reference<__bitset> reference;
565 typedef __bit_const_reference<__bitset> const_reference;
566 typedef __bit_iterator<__bitset, false> __iterator;
567 typedef __bit_iterator<__bitset, true> __const_iterator;
569 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
570 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
572 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT {
573 return reference(nullptr, 1);
575 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT {
576 return const_reference(nullptr, 1);
578 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t) _NOEXCEPT {
579 return __iterator(nullptr, 0);
581 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t) const _NOEXCEPT {
582 return __const_iterator(nullptr, 0);
585 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {}
586 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset&) _NOEXCEPT {}
587 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset&) _NOEXCEPT {}
589 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT {}
591 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return 0; }
592 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { return 0; }
594 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return true; }
595 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return false; }
597 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return 0; }
600 inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT {}
602 inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT {}
604 template <size_t _Size>
605 class _LIBCPP_TEMPLATE_VIS bitset;
606 template <size_t _Size>
607 struct hash<bitset<_Size> >;
609 template <size_t _Size>
610 class _LIBCPP_TEMPLATE_VIS bitset
611 : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> {
613 static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
614 typedef __bitset<__n_words, _Size> __base;
617 typedef typename __base::reference reference;
618 typedef typename __base::const_reference const_reference;
620 // 23.3.5.1 constructors:
621 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : __base(__v) {}
623 template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0>
624 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
626 #if _LIBCPP_STD_VER >= 26
627 typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos,
629 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
631 _CharT __zero = _CharT('0'),
632 _CharT __one = _CharT('1')) {
634 size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str));
635 __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one);
637 #if _LIBCPP_STD_VER >= 26
638 template <class _CharT, class _Traits>
639 _LIBCPP_HIDE_FROM_ABI constexpr explicit bitset(
640 basic_string_view<_CharT, _Traits> __str,
641 typename basic_string_view<_CharT, _Traits>::size_type __pos = 0,
642 typename basic_string_view<_CharT, _Traits>::size_type __n = basic_string_view<_CharT, _Traits>::npos,
643 _CharT __zero = _CharT('0'),
644 _CharT __one = _CharT('1')) {
645 if (__pos > __str.size())
646 __throw_out_of_range("bitset string pos out of range");
648 size_t __rlen = std::min(__n, __str.size() - __pos);
649 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);
652 template <class _CharT, class _Traits, class _Allocator>
653 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
654 const basic_string<_CharT, _Traits, _Allocator>& __str,
655 typename basic_string<_CharT, _Traits, _Allocator>::size_type __pos = 0,
656 typename basic_string<_CharT, _Traits, _Allocator>::size_type __n =
657 basic_string<_CharT, _Traits, _Allocator>::npos,
658 _CharT __zero = _CharT('0'),
659 _CharT __one = _CharT('1')) {
660 if (__pos > __str.size())
661 std::__throw_out_of_range("bitset string pos out of range");
663 size_t __rlen = std::min(__n, __str.size() - __pos);
664 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);
667 // 23.3.5.2 bitset operations:
668 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
669 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
670 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
671 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator<<=(size_t __pos) _NOEXCEPT;
672 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& operator>>=(size_t __pos) _NOEXCEPT;
673 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& set() _NOEXCEPT;
674 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& set(size_t __pos, bool __val = true);
675 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& reset() _NOEXCEPT;
676 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& reset(size_t __pos);
677 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator~() const _NOEXCEPT;
678 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip() _NOEXCEPT;
679 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip(size_t __pos);
682 #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
683 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { return __base::__make_ref(__p); }
685 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {
686 return __base::__make_ref(__p);
689 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {
690 return __base::__make_ref(__p);
692 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;
693 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;
694 template <class _CharT, class _Traits, class _Allocator>
695 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
696 to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;
697 template <class _CharT, class _Traits>
698 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, allocator<_CharT> >
699 to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;
700 template <class _CharT>
701 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
702 to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;
703 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<char, char_traits<char>, allocator<char> >
704 to_string(char __zero = '0', char __one = '1') const;
705 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t count() const _NOEXCEPT;
706 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT { return _Size; }
707 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT;
708 #if _LIBCPP_STD_VER <= 17
709 _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT;
711 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const;
712 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
713 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
714 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT { return !any(); }
715 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT;
716 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT;
719 template <class _CharT, class _Traits>
720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
721 __init_from_string_view(basic_string_view<_CharT, _Traits> __str, _CharT __zero, _CharT __one) {
722 for (size_t __i = 0; __i < __str.size(); ++__i)
723 if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one))
724 std::__throw_invalid_argument("bitset string ctor has invalid argument");
726 size_t __mp = std::min(__str.size(), _Size);
728 for (; __i < __mp; ++__i) {
729 _CharT __c = __str[__mp - 1 - __i];
730 (*this)[__i] = _Traits::eq(__c, __one);
732 std::fill(__base::__make_iter(__i), __base::__make_iter(_Size), false);
735 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); }
737 friend struct hash<bitset>;
740 template <size_t _Size>
741 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
742 bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT {
743 __base::operator&=(__rhs);
747 template <size_t _Size>
748 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
749 bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT {
750 __base::operator|=(__rhs);
754 template <size_t _Size>
755 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>&
756 bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT {
757 __base::operator^=(__rhs);
761 template <size_t _Size>
762 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT {
763 __pos = std::min(__pos, _Size);
764 std::copy_backward(__base::__make_iter(0), __base::__make_iter(_Size - __pos), __base::__make_iter(_Size));
765 std::fill_n(__base::__make_iter(0), __pos, false);
769 template <size_t _Size>
770 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT {
771 __pos = std::min(__pos, _Size);
772 std::copy(__base::__make_iter(__pos), __base::__make_iter(_Size), __base::__make_iter(0));
773 std::fill_n(__base::__make_iter(_Size - __pos), __pos, false);
777 template <size_t _Size>
778 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set() _NOEXCEPT {
779 std::fill_n(__base::__make_iter(0), _Size, true);
783 template <size_t _Size>
784 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set(size_t __pos, bool __val) {
786 __throw_out_of_range("bitset set argument out of range");
788 (*this)[__pos] = __val;
792 template <size_t _Size>
793 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT {
794 std::fill_n(__base::__make_iter(0), _Size, false);
798 template <size_t _Size>
799 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset(size_t __pos) {
801 __throw_out_of_range("bitset reset argument out of range");
803 (*this)[__pos] = false;
807 template <size_t _Size>
808 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> bitset<_Size>::operator~() const _NOEXCEPT {
814 template <size_t _Size>
815 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT {
820 template <size_t _Size>
821 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip(size_t __pos) {
823 __throw_out_of_range("bitset flip argument out of range");
825 reference __r = __base::__make_ref(__pos);
830 template <size_t _Size>
831 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const {
832 return __base::to_ulong();
835 template <size_t _Size>
836 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const {
837 return __base::to_ullong();
840 template <size_t _Size>
841 template <class _CharT, class _Traits, class _Allocator>
842 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
843 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const {
844 basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);
845 for (size_t __i = 0; __i != _Size; ++__i) {
847 __r[_Size - 1 - __i] = __one;
852 template <size_t _Size>
853 template <class _CharT, class _Traits>
854 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, allocator<_CharT> >
855 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const {
856 return to_string<_CharT, _Traits, allocator<_CharT> >(__zero, __one);
859 template <size_t _Size>
860 template <class _CharT>
861 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
862 bitset<_Size>::to_string(_CharT __zero, _CharT __one) const {
863 return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(__zero, __one);
866 template <size_t _Size>
867 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<char, char_traits<char>, allocator<char> >
868 bitset<_Size>::to_string(char __zero, char __one) const {
869 return to_string<char, char_traits<char>, allocator<char> >(__zero, __one);
872 template <size_t _Size>
873 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT {
874 return static_cast<size_t>(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true));
877 template <size_t _Size>
878 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
879 bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT {
880 return std::equal(__base::__make_iter(0), __base::__make_iter(_Size), __rhs.__make_iter(0));
883 #if _LIBCPP_STD_VER <= 17
885 template <size_t _Size>
886 inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT {
887 return !(*this == __rhs);
892 template <size_t _Size>
893 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const {
895 __throw_out_of_range("bitset test argument out of range");
897 return (*this)[__pos];
900 template <size_t _Size>
901 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::all() const _NOEXCEPT {
902 return __base::all();
905 template <size_t _Size>
906 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::any() const _NOEXCEPT {
907 return __base::any();
910 template <size_t _Size>
911 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
912 bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT {
918 template <size_t _Size>
919 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
920 bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT {
926 template <size_t _Size>
927 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
928 operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
929 bitset<_Size> __r = __x;
934 template <size_t _Size>
935 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
936 operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
937 bitset<_Size> __r = __x;
942 template <size_t _Size>
943 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
944 operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
945 bitset<_Size> __r = __x;
950 template <size_t _Size>
951 struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> > : public __unary_function<bitset<_Size>, size_t> {
952 _LIBCPP_HIDE_FROM_ABI size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT { return __bs.__hash_code(); }
955 template <class _CharT, class _Traits, size_t _Size>
956 _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
957 operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x);
959 template <class _CharT, class _Traits, size_t _Size>
960 _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
961 operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);
963 _LIBCPP_END_NAMESPACE_STD
967 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
970 # include <type_traits>
973 #endif // _LIBCPP_BITSET