146035553Spatrick// -*- C++ -*- 2*4bdff4beSrobert//===----------------------------------------------------------------------===// 346035553Spatrick// 446035553Spatrick// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 546035553Spatrick// See https://llvm.org/LICENSE.txt for license information. 646035553Spatrick// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 746035553Spatrick// 846035553Spatrick//===----------------------------------------------------------------------===// 946035553Spatrick 1046035553Spatrick#ifndef _LIBCPP_BITSET 1146035553Spatrick#define _LIBCPP_BITSET 1246035553Spatrick 1346035553Spatrick/* 1446035553Spatrick bitset synopsis 1546035553Spatrick 1646035553Spatricknamespace std 1746035553Spatrick{ 1846035553Spatrick 1946035553Spatricknamespace std { 2046035553Spatrick 2146035553Spatricktemplate <size_t N> 2246035553Spatrickclass bitset 2346035553Spatrick{ 2446035553Spatrickpublic: 2546035553Spatrick // bit reference: 2646035553Spatrick class reference 2746035553Spatrick { 2846035553Spatrick friend class bitset; 2946035553Spatrick reference() noexcept; 3046035553Spatrick public: 3146035553Spatrick ~reference() noexcept; 3246035553Spatrick reference& operator=(bool x) noexcept; // for b[i] = x; 3346035553Spatrick reference& operator=(const reference&) noexcept; // for b[i] = b[j]; 3446035553Spatrick bool operator~() const noexcept; // flips the bit 3546035553Spatrick operator bool() const noexcept; // for x = b[i]; 3646035553Spatrick reference& flip() noexcept; // for b[i].flip(); 3746035553Spatrick }; 3846035553Spatrick 3946035553Spatrick // 23.3.5.1 constructors: 4046035553Spatrick constexpr bitset() noexcept; 4146035553Spatrick constexpr bitset(unsigned long long val) noexcept; 4246035553Spatrick template <class charT> 4346035553Spatrick explicit bitset(const charT* str, 4446035553Spatrick typename basic_string<charT>::size_type n = basic_string<charT>::npos, 45*4bdff4beSrobert charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23 4646035553Spatrick template<class charT, class traits, class Allocator> 4746035553Spatrick explicit bitset(const basic_string<charT,traits,Allocator>& str, 4846035553Spatrick typename basic_string<charT,traits,Allocator>::size_type pos = 0, 4946035553Spatrick typename basic_string<charT,traits,Allocator>::size_type n = 5046035553Spatrick basic_string<charT,traits,Allocator>::npos, 51*4bdff4beSrobert charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23 5246035553Spatrick 5346035553Spatrick // 23.3.5.2 bitset operations: 54*4bdff4beSrobert bitset& operator&=(const bitset& rhs) noexcept; // constexpr since C++23 55*4bdff4beSrobert bitset& operator|=(const bitset& rhs) noexcept; // constexpr since C++23 56*4bdff4beSrobert bitset& operator^=(const bitset& rhs) noexcept; // constexpr since C++23 57*4bdff4beSrobert bitset& operator<<=(size_t pos) noexcept; // constexpr since C++23 58*4bdff4beSrobert bitset& operator>>=(size_t pos) noexcept; // constexpr since C++23 59*4bdff4beSrobert bitset& set() noexcept; // constexpr since C++23 60*4bdff4beSrobert bitset& set(size_t pos, bool val = true); // constexpr since C++23 61*4bdff4beSrobert bitset& reset() noexcept; // constexpr since C++23 62*4bdff4beSrobert bitset& reset(size_t pos); // constexpr since C++23 63*4bdff4beSrobert bitset operator~() const noexcept; // constexpr since C++23 64*4bdff4beSrobert bitset& flip() noexcept; // constexpr since C++23 65*4bdff4beSrobert bitset& flip(size_t pos); // constexpr since C++23 6646035553Spatrick 6746035553Spatrick // element access: 68*4bdff4beSrobert constexpr bool operator[](size_t pos) const; 69*4bdff4beSrobert reference operator[](size_t pos); // constexpr since C++23 70*4bdff4beSrobert unsigned long to_ulong() const; // constexpr since C++23 71*4bdff4beSrobert unsigned long long to_ullong() const; // constexpr since C++23 72*4bdff4beSrobert template <class charT, class traits, class Allocator> // constexpr since C++23 7346035553Spatrick basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const; 74*4bdff4beSrobert template <class charT, class traits> // constexpr since C++23 7546035553Spatrick basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const; 76*4bdff4beSrobert template <class charT> // constexpr since C++23 7746035553Spatrick basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const; 78*4bdff4beSrobert basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const; // constexpr since C++23 79*4bdff4beSrobert size_t count() const noexcept; // constexpr since C++23 80*4bdff4beSrobert constexpr size_t size() const noexcept; // constexpr since C++23 81*4bdff4beSrobert bool operator==(const bitset& rhs) const noexcept; // constexpr since C++23 82*4bdff4beSrobert bool operator!=(const bitset& rhs) const noexcept; // constexpr since C++23 83*4bdff4beSrobert bool test(size_t pos) const; // constexpr since C++23 84*4bdff4beSrobert bool all() const noexcept; // constexpr since C++23 85*4bdff4beSrobert bool any() const noexcept; // constexpr since C++23 86*4bdff4beSrobert bool none() const noexcept; // constexpr since C++23 87*4bdff4beSrobert bitset<N> operator<<(size_t pos) const noexcept; // constexpr since C++23 88*4bdff4beSrobert bitset<N> operator>>(size_t pos) const noexcept; // constexpr since C++23 8946035553Spatrick}; 9046035553Spatrick 9146035553Spatrick// 23.3.5.3 bitset operators: 9246035553Spatricktemplate <size_t N> 93*4bdff4beSrobertbitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23 9446035553Spatrick 9546035553Spatricktemplate <size_t N> 96*4bdff4beSrobertbitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23 9746035553Spatrick 9846035553Spatricktemplate <size_t N> 99*4bdff4beSrobertbitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23 10046035553Spatrick 10146035553Spatricktemplate <class charT, class traits, size_t N> 10246035553Spatrickbasic_istream<charT, traits>& 10346035553Spatrickoperator>>(basic_istream<charT, traits>& is, bitset<N>& x); 10446035553Spatrick 10546035553Spatricktemplate <class charT, class traits, size_t N> 10646035553Spatrickbasic_ostream<charT, traits>& 10746035553Spatrickoperator<<(basic_ostream<charT, traits>& os, const bitset<N>& x); 10846035553Spatrick 10946035553Spatricktemplate <size_t N> struct hash<std::bitset<N>>; 11046035553Spatrick 11146035553Spatrick} // std 11246035553Spatrick 11346035553Spatrick*/ 11446035553Spatrick 115*4bdff4beSrobert#include <__algorithm/fill.h> 116*4bdff4beSrobert#include <__assert> // all public C++ headers provide the assertion handler 11746035553Spatrick#include <__bit_reference> 118*4bdff4beSrobert#include <__config> 119*4bdff4beSrobert#include <__functional/hash.h> 120*4bdff4beSrobert#include <__functional/unary_function.h> 121*4bdff4beSrobert#include <__type_traits/is_char_like_type.h> 12276d0caaeSpatrick#include <climits> 12376d0caaeSpatrick#include <cstddef> 12476d0caaeSpatrick#include <stdexcept> 125*4bdff4beSrobert#include <version> 126*4bdff4beSrobert 127*4bdff4beSrobert// standard-mandated includes 128*4bdff4beSrobert 129*4bdff4beSrobert// [bitset.syn] 130*4bdff4beSrobert#include <iosfwd> 13176d0caaeSpatrick#include <string> 13246035553Spatrick 13346035553Spatrick#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 13446035553Spatrick# pragma GCC system_header 13546035553Spatrick#endif 13646035553Spatrick 13746035553Spatrick_LIBCPP_PUSH_MACROS 13846035553Spatrick#include <__undef_macros> 13946035553Spatrick 14046035553Spatrick 14146035553Spatrick_LIBCPP_BEGIN_NAMESPACE_STD 14246035553Spatrick 14346035553Spatricktemplate <size_t _N_words, size_t _Size> 14446035553Spatrickclass __bitset; 14546035553Spatrick 14646035553Spatricktemplate <size_t _N_words, size_t _Size> 14746035553Spatrickstruct __has_storage_type<__bitset<_N_words, _Size> > 14846035553Spatrick{ 14946035553Spatrick static const bool value = true; 15046035553Spatrick}; 15146035553Spatrick 15246035553Spatricktemplate <size_t _N_words, size_t _Size> 15346035553Spatrickclass __bitset 15446035553Spatrick{ 15546035553Spatrickpublic: 15646035553Spatrick typedef ptrdiff_t difference_type; 15746035553Spatrick typedef size_t size_type; 15846035553Spatrick typedef size_type __storage_type; 15946035553Spatrickprotected: 16046035553Spatrick typedef __bitset __self; 16146035553Spatrick typedef __storage_type* __storage_pointer; 16246035553Spatrick typedef const __storage_type* __const_storage_pointer; 16346035553Spatrick static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 16446035553Spatrick 16546035553Spatrick friend class __bit_reference<__bitset>; 16646035553Spatrick friend class __bit_const_reference<__bitset>; 16746035553Spatrick friend class __bit_iterator<__bitset, false>; 16846035553Spatrick friend class __bit_iterator<__bitset, true>; 16946035553Spatrick friend struct __bit_array<__bitset>; 17046035553Spatrick 17146035553Spatrick __storage_type __first_[_N_words]; 17246035553Spatrick 17346035553Spatrick typedef __bit_reference<__bitset> reference; 17446035553Spatrick typedef __bit_const_reference<__bitset> const_reference; 17546035553Spatrick typedef __bit_iterator<__bitset, false> iterator; 17646035553Spatrick typedef __bit_iterator<__bitset, true> const_iterator; 17746035553Spatrick 17846035553Spatrick _LIBCPP_INLINE_VISIBILITY 17946035553Spatrick _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 18046035553Spatrick _LIBCPP_INLINE_VISIBILITY 18146035553Spatrick explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; 18246035553Spatrick 183*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT 18446035553Spatrick {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} 18546035553Spatrick _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT 18646035553Spatrick {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} 187*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT 18846035553Spatrick {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 189*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT 19046035553Spatrick {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 19146035553Spatrick 192*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 19346035553Spatrick void operator&=(const __bitset& __v) _NOEXCEPT; 194*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 19546035553Spatrick void operator|=(const __bitset& __v) _NOEXCEPT; 196*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 19746035553Spatrick void operator^=(const __bitset& __v) _NOEXCEPT; 19846035553Spatrick 199*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT; 200*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const 20146035553Spatrick {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());} 202*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const 20346035553Spatrick {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());} 20446035553Spatrick 205*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT; 206*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT; 20746035553Spatrick _LIBCPP_INLINE_VISIBILITY 20846035553Spatrick size_t __hash_code() const _NOEXCEPT; 20946035553Spatrickprivate: 21046035553Spatrick#ifdef _LIBCPP_CXX03_LANG 21146035553Spatrick void __init(unsigned long long __v, false_type) _NOEXCEPT; 21246035553Spatrick _LIBCPP_INLINE_VISIBILITY 21346035553Spatrick void __init(unsigned long long __v, true_type) _NOEXCEPT; 21446035553Spatrick#endif // _LIBCPP_CXX03_LANG 215*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 21646035553Spatrick unsigned long to_ulong(false_type) const; 217*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 21846035553Spatrick unsigned long to_ulong(true_type) const; 219*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 22046035553Spatrick unsigned long long to_ullong(false_type) const; 221*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 22246035553Spatrick unsigned long long to_ullong(true_type) const; 223*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 22446035553Spatrick unsigned long long to_ullong(true_type, false_type) const; 225*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 22646035553Spatrick unsigned long long to_ullong(true_type, true_type) const; 22746035553Spatrick}; 22846035553Spatrick 22946035553Spatricktemplate <size_t _N_words, size_t _Size> 23046035553Spatrickinline 23146035553Spatrick_LIBCPP_CONSTEXPR 23246035553Spatrick__bitset<_N_words, _Size>::__bitset() _NOEXCEPT 23346035553Spatrick#ifndef _LIBCPP_CXX03_LANG 23446035553Spatrick : __first_{0} 23546035553Spatrick#endif 23646035553Spatrick{ 23746035553Spatrick#ifdef _LIBCPP_CXX03_LANG 23846035553Spatrick _VSTD::fill_n(__first_, _N_words, __storage_type(0)); 23946035553Spatrick#endif 24046035553Spatrick} 24146035553Spatrick 24246035553Spatrick#ifdef _LIBCPP_CXX03_LANG 24346035553Spatrick 24446035553Spatricktemplate <size_t _N_words, size_t _Size> 24546035553Spatrickvoid 24646035553Spatrick__bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT 24746035553Spatrick{ 24846035553Spatrick __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)]; 24946035553Spatrick size_t __sz = _Size; 25046035553Spatrick for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word ) 25146035553Spatrick if ( __sz < __bits_per_word) 25246035553Spatrick __t[__i] = static_cast<__storage_type>(__v) & ( 1ULL << __sz ) - 1; 25346035553Spatrick else 25446035553Spatrick __t[__i] = static_cast<__storage_type>(__v); 25546035553Spatrick 25646035553Spatrick _VSTD::copy(__t, __t + sizeof(__t)/sizeof(__t[0]), __first_); 25746035553Spatrick _VSTD::fill(__first_ + sizeof(__t)/sizeof(__t[0]), __first_ + sizeof(__first_)/sizeof(__first_[0]), 25846035553Spatrick __storage_type(0)); 25946035553Spatrick} 26046035553Spatrick 26146035553Spatricktemplate <size_t _N_words, size_t _Size> 26246035553Spatrickinline _LIBCPP_INLINE_VISIBILITY 26346035553Spatrickvoid 26446035553Spatrick__bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT 26546035553Spatrick{ 26646035553Spatrick __first_[0] = __v; 26746035553Spatrick if (_Size < __bits_per_word) 26846035553Spatrick __first_[0] &= ( 1ULL << _Size ) - 1; 26946035553Spatrick 27046035553Spatrick _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0)); 27146035553Spatrick} 27246035553Spatrick 27346035553Spatrick#endif // _LIBCPP_CXX03_LANG 27446035553Spatrick 27546035553Spatricktemplate <size_t _N_words, size_t _Size> 27646035553Spatrickinline 27746035553Spatrick_LIBCPP_CONSTEXPR 27846035553Spatrick__bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT 27946035553Spatrick#ifndef _LIBCPP_CXX03_LANG 28046035553Spatrick#if __SIZEOF_SIZE_T__ == 8 28146035553Spatrick : __first_{__v} 28246035553Spatrick#elif __SIZEOF_SIZE_T__ == 4 28346035553Spatrick : __first_{static_cast<__storage_type>(__v), 28446035553Spatrick _Size >= 2 * __bits_per_word ? static_cast<__storage_type>(__v >> __bits_per_word) 28546035553Spatrick : static_cast<__storage_type>((__v >> __bits_per_word) & (__storage_type(1) << (_Size - __bits_per_word)) - 1)} 28646035553Spatrick#else 28746035553Spatrick#error This constructor has not been ported to this platform 28846035553Spatrick#endif 28946035553Spatrick#endif 29046035553Spatrick{ 29146035553Spatrick#ifdef _LIBCPP_CXX03_LANG 29246035553Spatrick __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>()); 29346035553Spatrick#endif 29446035553Spatrick} 29546035553Spatrick 29646035553Spatricktemplate <size_t _N_words, size_t _Size> 29746035553Spatrickinline 298*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void 29946035553Spatrick__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT 30046035553Spatrick{ 30146035553Spatrick for (size_type __i = 0; __i < _N_words; ++__i) 30246035553Spatrick __first_[__i] &= __v.__first_[__i]; 30346035553Spatrick} 30446035553Spatrick 30546035553Spatricktemplate <size_t _N_words, size_t _Size> 30646035553Spatrickinline 307*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void 30846035553Spatrick__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT 30946035553Spatrick{ 31046035553Spatrick for (size_type __i = 0; __i < _N_words; ++__i) 31146035553Spatrick __first_[__i] |= __v.__first_[__i]; 31246035553Spatrick} 31346035553Spatrick 31446035553Spatricktemplate <size_t _N_words, size_t _Size> 31546035553Spatrickinline 316*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void 31746035553Spatrick__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT 31846035553Spatrick{ 31946035553Spatrick for (size_type __i = 0; __i < _N_words; ++__i) 32046035553Spatrick __first_[__i] ^= __v.__first_[__i]; 32146035553Spatrick} 32246035553Spatrick 32346035553Spatricktemplate <size_t _N_words, size_t _Size> 324*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void 32546035553Spatrick__bitset<_N_words, _Size>::flip() _NOEXCEPT 32646035553Spatrick{ 32746035553Spatrick // do middle whole words 32846035553Spatrick size_type __n = _Size; 32946035553Spatrick __storage_pointer __p = __first_; 33046035553Spatrick for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 33146035553Spatrick *__p = ~*__p; 33246035553Spatrick // do last partial word 33346035553Spatrick if (__n > 0) 33446035553Spatrick { 33546035553Spatrick __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 33646035553Spatrick __storage_type __b = *__p & __m; 33746035553Spatrick *__p &= ~__m; 33846035553Spatrick *__p |= ~__b & __m; 33946035553Spatrick } 34046035553Spatrick} 34146035553Spatrick 34246035553Spatricktemplate <size_t _N_words, size_t _Size> 343*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long 34446035553Spatrick__bitset<_N_words, _Size>::to_ulong(false_type) const 34546035553Spatrick{ 34646035553Spatrick const_iterator __e = __make_iter(_Size); 34746035553Spatrick const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true); 34846035553Spatrick if (__i != __e) 34946035553Spatrick __throw_overflow_error("bitset to_ulong overflow error"); 35046035553Spatrick 35146035553Spatrick return __first_[0]; 35246035553Spatrick} 35346035553Spatrick 35446035553Spatricktemplate <size_t _N_words, size_t _Size> 35546035553Spatrickinline 356*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long 35746035553Spatrick__bitset<_N_words, _Size>::to_ulong(true_type) const 35846035553Spatrick{ 35946035553Spatrick return __first_[0]; 36046035553Spatrick} 36146035553Spatrick 36246035553Spatricktemplate <size_t _N_words, size_t _Size> 363*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long 36446035553Spatrick__bitset<_N_words, _Size>::to_ullong(false_type) const 36546035553Spatrick{ 36646035553Spatrick const_iterator __e = __make_iter(_Size); 36746035553Spatrick const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true); 36846035553Spatrick if (__i != __e) 36946035553Spatrick __throw_overflow_error("bitset to_ullong overflow error"); 37046035553Spatrick 37146035553Spatrick return to_ullong(true_type()); 37246035553Spatrick} 37346035553Spatrick 37446035553Spatricktemplate <size_t _N_words, size_t _Size> 37546035553Spatrickinline 376*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long 37746035553Spatrick__bitset<_N_words, _Size>::to_ullong(true_type) const 37846035553Spatrick{ 37946035553Spatrick return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>()); 38046035553Spatrick} 38146035553Spatrick 38246035553Spatricktemplate <size_t _N_words, size_t _Size> 38346035553Spatrickinline 384*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long 38546035553Spatrick__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const 38646035553Spatrick{ 38746035553Spatrick return __first_[0]; 38846035553Spatrick} 38946035553Spatrick 39046035553Spatricktemplate <size_t _N_words, size_t _Size> 391*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long 39246035553Spatrick__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const 39346035553Spatrick{ 39446035553Spatrick unsigned long long __r = __first_[0]; 39576d0caaeSpatrick for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i) 39646035553Spatrick __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT); 39746035553Spatrick return __r; 39846035553Spatrick} 39946035553Spatrick 40046035553Spatricktemplate <size_t _N_words, size_t _Size> 401*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool 40246035553Spatrick__bitset<_N_words, _Size>::all() const _NOEXCEPT 40346035553Spatrick{ 40446035553Spatrick // do middle whole words 40546035553Spatrick size_type __n = _Size; 40646035553Spatrick __const_storage_pointer __p = __first_; 40746035553Spatrick for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 40846035553Spatrick if (~*__p) 40946035553Spatrick return false; 41046035553Spatrick // do last partial word 41146035553Spatrick if (__n > 0) 41246035553Spatrick { 41346035553Spatrick __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 41446035553Spatrick if (~*__p & __m) 41546035553Spatrick return false; 41646035553Spatrick } 41746035553Spatrick return true; 41846035553Spatrick} 41946035553Spatrick 42046035553Spatricktemplate <size_t _N_words, size_t _Size> 421*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool 42246035553Spatrick__bitset<_N_words, _Size>::any() const _NOEXCEPT 42346035553Spatrick{ 42446035553Spatrick // do middle whole words 42546035553Spatrick size_type __n = _Size; 42646035553Spatrick __const_storage_pointer __p = __first_; 42746035553Spatrick for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 42846035553Spatrick if (*__p) 42946035553Spatrick return true; 43046035553Spatrick // do last partial word 43146035553Spatrick if (__n > 0) 43246035553Spatrick { 43346035553Spatrick __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 43446035553Spatrick if (*__p & __m) 43546035553Spatrick return true; 43646035553Spatrick } 43746035553Spatrick return false; 43846035553Spatrick} 43946035553Spatrick 44046035553Spatricktemplate <size_t _N_words, size_t _Size> 44146035553Spatrickinline 44246035553Spatricksize_t 44346035553Spatrick__bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT 44446035553Spatrick{ 44546035553Spatrick size_t __h = 0; 44646035553Spatrick for (size_type __i = 0; __i < _N_words; ++__i) 44746035553Spatrick __h ^= __first_[__i]; 44846035553Spatrick return __h; 44946035553Spatrick} 45046035553Spatrick 45146035553Spatricktemplate <size_t _Size> 45246035553Spatrickclass __bitset<1, _Size> 45346035553Spatrick{ 45446035553Spatrickpublic: 45546035553Spatrick typedef ptrdiff_t difference_type; 45646035553Spatrick typedef size_t size_type; 45746035553Spatrick typedef size_type __storage_type; 45846035553Spatrickprotected: 45946035553Spatrick typedef __bitset __self; 46046035553Spatrick typedef __storage_type* __storage_pointer; 46146035553Spatrick typedef const __storage_type* __const_storage_pointer; 46246035553Spatrick static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 46346035553Spatrick 46446035553Spatrick friend class __bit_reference<__bitset>; 46546035553Spatrick friend class __bit_const_reference<__bitset>; 46646035553Spatrick friend class __bit_iterator<__bitset, false>; 46746035553Spatrick friend class __bit_iterator<__bitset, true>; 46846035553Spatrick friend struct __bit_array<__bitset>; 46946035553Spatrick 47046035553Spatrick __storage_type __first_; 47146035553Spatrick 47246035553Spatrick typedef __bit_reference<__bitset> reference; 47346035553Spatrick typedef __bit_const_reference<__bitset> const_reference; 47446035553Spatrick typedef __bit_iterator<__bitset, false> iterator; 47546035553Spatrick typedef __bit_iterator<__bitset, true> const_iterator; 47646035553Spatrick 47746035553Spatrick _LIBCPP_INLINE_VISIBILITY 47846035553Spatrick _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 47946035553Spatrick _LIBCPP_INLINE_VISIBILITY 48046035553Spatrick explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; 48146035553Spatrick 482*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT 48346035553Spatrick {return reference(&__first_, __storage_type(1) << __pos);} 48446035553Spatrick _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT 48546035553Spatrick {return const_reference(&__first_, __storage_type(1) << __pos);} 486*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT 48746035553Spatrick {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 488*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT 48946035553Spatrick {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 49046035553Spatrick 491*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 49246035553Spatrick void operator&=(const __bitset& __v) _NOEXCEPT; 493*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 49446035553Spatrick void operator|=(const __bitset& __v) _NOEXCEPT; 495*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 49646035553Spatrick void operator^=(const __bitset& __v) _NOEXCEPT; 49746035553Spatrick 498*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 49946035553Spatrick void flip() _NOEXCEPT; 50046035553Spatrick 501*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 50246035553Spatrick unsigned long to_ulong() const; 503*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 50446035553Spatrick unsigned long long to_ullong() const; 50546035553Spatrick 506*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 50746035553Spatrick bool all() const _NOEXCEPT; 508*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 50946035553Spatrick bool any() const _NOEXCEPT; 51046035553Spatrick 51146035553Spatrick _LIBCPP_INLINE_VISIBILITY 51246035553Spatrick size_t __hash_code() const _NOEXCEPT; 51346035553Spatrick}; 51446035553Spatrick 51546035553Spatricktemplate <size_t _Size> 51646035553Spatrickinline 51746035553Spatrick_LIBCPP_CONSTEXPR 51846035553Spatrick__bitset<1, _Size>::__bitset() _NOEXCEPT 51946035553Spatrick : __first_(0) 52046035553Spatrick{ 52146035553Spatrick} 52246035553Spatrick 52346035553Spatricktemplate <size_t _Size> 52446035553Spatrickinline 52546035553Spatrick_LIBCPP_CONSTEXPR 52646035553Spatrick__bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT 52746035553Spatrick : __first_( 52846035553Spatrick _Size == __bits_per_word ? static_cast<__storage_type>(__v) 52946035553Spatrick : static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1) 53046035553Spatrick ) 53146035553Spatrick{ 53246035553Spatrick} 53346035553Spatrick 53446035553Spatricktemplate <size_t _Size> 53546035553Spatrickinline 536*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void 53746035553Spatrick__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT 53846035553Spatrick{ 53946035553Spatrick __first_ &= __v.__first_; 54046035553Spatrick} 54146035553Spatrick 54246035553Spatricktemplate <size_t _Size> 54346035553Spatrickinline 544*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void 54546035553Spatrick__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT 54646035553Spatrick{ 54746035553Spatrick __first_ |= __v.__first_; 54846035553Spatrick} 54946035553Spatrick 55046035553Spatricktemplate <size_t _Size> 55146035553Spatrickinline 552*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void 55346035553Spatrick__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT 55446035553Spatrick{ 55546035553Spatrick __first_ ^= __v.__first_; 55646035553Spatrick} 55746035553Spatrick 55846035553Spatricktemplate <size_t _Size> 55946035553Spatrickinline 560*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void 56146035553Spatrick__bitset<1, _Size>::flip() _NOEXCEPT 56246035553Spatrick{ 56346035553Spatrick __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 56446035553Spatrick __first_ = ~__first_; 56546035553Spatrick __first_ &= __m; 56646035553Spatrick} 56746035553Spatrick 56846035553Spatricktemplate <size_t _Size> 56946035553Spatrickinline 570*4bdff4beSrobert_LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long 57146035553Spatrick__bitset<1, _Size>::to_ulong() const 57246035553Spatrick{ 57346035553Spatrick return __first_; 57446035553Spatrick} 57546035553Spatrick 57646035553Spatricktemplate <size_t _Size> 57746035553Spatrickinline 578*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long 57946035553Spatrick__bitset<1, _Size>::to_ullong() const 58046035553Spatrick{ 58146035553Spatrick return __first_; 58246035553Spatrick} 58346035553Spatrick 58446035553Spatricktemplate <size_t _Size> 58546035553Spatrickinline 586*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool 58746035553Spatrick__bitset<1, _Size>::all() const _NOEXCEPT 58846035553Spatrick{ 58946035553Spatrick __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 59046035553Spatrick return !(~__first_ & __m); 59146035553Spatrick} 59246035553Spatrick 59346035553Spatricktemplate <size_t _Size> 59446035553Spatrickinline 595*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool 59646035553Spatrick__bitset<1, _Size>::any() const _NOEXCEPT 59746035553Spatrick{ 59846035553Spatrick __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 59946035553Spatrick return __first_ & __m; 60046035553Spatrick} 60146035553Spatrick 60246035553Spatricktemplate <size_t _Size> 60346035553Spatrickinline 60446035553Spatricksize_t 60546035553Spatrick__bitset<1, _Size>::__hash_code() const _NOEXCEPT 60646035553Spatrick{ 60746035553Spatrick return __first_; 60846035553Spatrick} 60946035553Spatrick 61046035553Spatricktemplate <> 61146035553Spatrickclass __bitset<0, 0> 61246035553Spatrick{ 61346035553Spatrickpublic: 61446035553Spatrick typedef ptrdiff_t difference_type; 61546035553Spatrick typedef size_t size_type; 61646035553Spatrick typedef size_type __storage_type; 61746035553Spatrickprotected: 61846035553Spatrick typedef __bitset __self; 61946035553Spatrick typedef __storage_type* __storage_pointer; 62046035553Spatrick typedef const __storage_type* __const_storage_pointer; 62146035553Spatrick static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 62246035553Spatrick 62346035553Spatrick friend class __bit_reference<__bitset>; 62446035553Spatrick friend class __bit_const_reference<__bitset>; 62546035553Spatrick friend class __bit_iterator<__bitset, false>; 62646035553Spatrick friend class __bit_iterator<__bitset, true>; 62746035553Spatrick friend struct __bit_array<__bitset>; 62846035553Spatrick 62946035553Spatrick typedef __bit_reference<__bitset> reference; 63046035553Spatrick typedef __bit_const_reference<__bitset> const_reference; 63146035553Spatrick typedef __bit_iterator<__bitset, false> iterator; 63246035553Spatrick typedef __bit_iterator<__bitset, true> const_iterator; 63346035553Spatrick 63446035553Spatrick _LIBCPP_INLINE_VISIBILITY 63546035553Spatrick _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 63646035553Spatrick _LIBCPP_INLINE_VISIBILITY 63746035553Spatrick explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; 63846035553Spatrick 639*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT 64076d0caaeSpatrick {return reference(nullptr, 1);} 64146035553Spatrick _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT 64276d0caaeSpatrick {return const_reference(nullptr, 1);} 643*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t) _NOEXCEPT 64476d0caaeSpatrick {return iterator(nullptr, 0);} 645*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t) const _NOEXCEPT 64676d0caaeSpatrick {return const_iterator(nullptr, 0);} 64746035553Spatrick 648*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {} 649*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset&) _NOEXCEPT {} 650*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset&) _NOEXCEPT {} 65146035553Spatrick 652*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT {} 65346035553Spatrick 654*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {return 0;} 655*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {return 0;} 65646035553Spatrick 657*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT {return true;} 658*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT {return false;} 65946035553Spatrick 66046035553Spatrick _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;} 66146035553Spatrick}; 66246035553Spatrick 66346035553Spatrickinline 66446035553Spatrick_LIBCPP_CONSTEXPR 66546035553Spatrick__bitset<0, 0>::__bitset() _NOEXCEPT 66646035553Spatrick{ 66746035553Spatrick} 66846035553Spatrick 66946035553Spatrickinline 67046035553Spatrick_LIBCPP_CONSTEXPR 67146035553Spatrick__bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT 67246035553Spatrick{ 67346035553Spatrick} 67446035553Spatrick 67546035553Spatricktemplate <size_t _Size> class _LIBCPP_TEMPLATE_VIS bitset; 67646035553Spatricktemplate <size_t _Size> struct hash<bitset<_Size> >; 67746035553Spatrick 67846035553Spatricktemplate <size_t _Size> 67946035553Spatrickclass _LIBCPP_TEMPLATE_VIS bitset 68046035553Spatrick : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> 68146035553Spatrick{ 68246035553Spatrickpublic: 68346035553Spatrick static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1; 68446035553Spatrick typedef __bitset<__n_words, _Size> base; 68546035553Spatrick 68646035553Spatrickpublic: 68746035553Spatrick typedef typename base::reference reference; 68846035553Spatrick typedef typename base::const_reference const_reference; 68946035553Spatrick 69046035553Spatrick // 23.3.5.1 constructors: 69146035553Spatrick _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} 69246035553Spatrick _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 69346035553Spatrick bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} 694*4bdff4beSrobert template<class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> > 695*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 69646035553Spatrick explicit bitset(const _CharT* __str, 69746035553Spatrick typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, 69846035553Spatrick _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); 69946035553Spatrick template<class _CharT, class _Traits, class _Allocator> 700*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 70146035553Spatrick explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, 70246035553Spatrick typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0, 70346035553Spatrick typename basic_string<_CharT,_Traits,_Allocator>::size_type __n = 70446035553Spatrick (basic_string<_CharT,_Traits,_Allocator>::npos), 70546035553Spatrick _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); 70646035553Spatrick 70746035553Spatrick // 23.3.5.2 bitset operations: 708*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 70946035553Spatrick bitset& operator&=(const bitset& __rhs) _NOEXCEPT; 710*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 71146035553Spatrick bitset& operator|=(const bitset& __rhs) _NOEXCEPT; 712*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 71346035553Spatrick bitset& operator^=(const bitset& __rhs) _NOEXCEPT; 714*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 71546035553Spatrick bitset& operator<<=(size_t __pos) _NOEXCEPT; 716*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 71746035553Spatrick bitset& operator>>=(size_t __pos) _NOEXCEPT; 718*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 71946035553Spatrick bitset& set() _NOEXCEPT; 720*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 72146035553Spatrick bitset& set(size_t __pos, bool __val = true); 722*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 72346035553Spatrick bitset& reset() _NOEXCEPT; 724*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 72546035553Spatrick bitset& reset(size_t __pos); 726*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 72746035553Spatrick bitset operator~() const _NOEXCEPT; 728*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 72946035553Spatrick bitset& flip() _NOEXCEPT; 730*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 73146035553Spatrick bitset& flip(size_t __pos); 73246035553Spatrick 73346035553Spatrick // element access: 734*4bdff4beSrobert#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL 735*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const {return base::__make_ref(__p);} 736*4bdff4beSrobert#else 737*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);} 738*4bdff4beSrobert#endif 739*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {return base::__make_ref(__p);} 740*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 74146035553Spatrick unsigned long to_ulong() const; 742*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 74346035553Spatrick unsigned long long to_ullong() const; 74446035553Spatrick template <class _CharT, class _Traits, class _Allocator> 745*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 74646035553Spatrick basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'), 74746035553Spatrick _CharT __one = _CharT('1')) const; 74846035553Spatrick template <class _CharT, class _Traits> 749*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 75046035553Spatrick basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), 75146035553Spatrick _CharT __one = _CharT('1')) const; 75246035553Spatrick template <class _CharT> 753*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 75446035553Spatrick basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), 75546035553Spatrick _CharT __one = _CharT('1')) const; 756*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 75746035553Spatrick basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0', 75846035553Spatrick char __one = '1') const; 759*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 76046035553Spatrick size_t count() const _NOEXCEPT; 76146035553Spatrick _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;} 762*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 76346035553Spatrick bool operator==(const bitset& __rhs) const _NOEXCEPT; 764*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 76546035553Spatrick bool operator!=(const bitset& __rhs) const _NOEXCEPT; 766*4bdff4beSrobert _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 76746035553Spatrick bool test(size_t __pos) const; 768*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 76946035553Spatrick bool all() const _NOEXCEPT; 770*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 77146035553Spatrick bool any() const _NOEXCEPT; 772*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT {return !any();} 773*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 77446035553Spatrick bitset operator<<(size_t __pos) const _NOEXCEPT; 775*4bdff4beSrobert _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 77646035553Spatrick bitset operator>>(size_t __pos) const _NOEXCEPT; 77746035553Spatrick 77846035553Spatrickprivate: 77946035553Spatrick 78046035553Spatrick _LIBCPP_INLINE_VISIBILITY 78146035553Spatrick size_t __hash_code() const _NOEXCEPT {return base::__hash_code();} 78246035553Spatrick 78346035553Spatrick friend struct hash<bitset>; 78446035553Spatrick}; 78546035553Spatrick 78646035553Spatricktemplate <size_t _Size> 78746035553Spatricktemplate<class _CharT, class> 788*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 78946035553Spatrickbitset<_Size>::bitset(const _CharT* __str, 79046035553Spatrick typename basic_string<_CharT>::size_type __n, 79146035553Spatrick _CharT __zero, _CharT __one) 79246035553Spatrick{ 79346035553Spatrick size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str)); 79446035553Spatrick for (size_t __i = 0; __i < __rlen; ++__i) 79546035553Spatrick if (__str[__i] != __zero && __str[__i] != __one) 79646035553Spatrick __throw_invalid_argument("bitset string ctor has invalid argument"); 79746035553Spatrick 79846035553Spatrick size_t _Mp = _VSTD::min(__rlen, _Size); 79946035553Spatrick size_t __i = 0; 80046035553Spatrick for (; __i < _Mp; ++__i) 80146035553Spatrick { 80246035553Spatrick _CharT __c = __str[_Mp - 1 - __i]; 80376d0caaeSpatrick (*this)[__i] = (__c == __one); 80446035553Spatrick } 80546035553Spatrick _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false); 80646035553Spatrick} 80746035553Spatrick 80846035553Spatricktemplate <size_t _Size> 80946035553Spatricktemplate<class _CharT, class _Traits, class _Allocator> 810*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 81146035553Spatrickbitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, 81246035553Spatrick typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos, 81346035553Spatrick typename basic_string<_CharT,_Traits,_Allocator>::size_type __n, 81446035553Spatrick _CharT __zero, _CharT __one) 81546035553Spatrick{ 81646035553Spatrick if (__pos > __str.size()) 81746035553Spatrick __throw_out_of_range("bitset string pos out of range"); 81846035553Spatrick 81946035553Spatrick size_t __rlen = _VSTD::min(__n, __str.size() - __pos); 82046035553Spatrick for (size_t __i = __pos; __i < __pos + __rlen; ++__i) 82146035553Spatrick if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one)) 82246035553Spatrick __throw_invalid_argument("bitset string ctor has invalid argument"); 82346035553Spatrick 82446035553Spatrick size_t _Mp = _VSTD::min(__rlen, _Size); 82546035553Spatrick size_t __i = 0; 82646035553Spatrick for (; __i < _Mp; ++__i) 82746035553Spatrick { 82846035553Spatrick _CharT __c = __str[__pos + _Mp - 1 - __i]; 82976d0caaeSpatrick (*this)[__i] = _Traits::eq(__c, __one); 83046035553Spatrick } 83146035553Spatrick _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false); 83246035553Spatrick} 83346035553Spatrick 83446035553Spatricktemplate <size_t _Size> 83546035553Spatrickinline 836*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 83746035553Spatrickbitset<_Size>& 83846035553Spatrickbitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT 83946035553Spatrick{ 84046035553Spatrick base::operator&=(__rhs); 84146035553Spatrick return *this; 84246035553Spatrick} 84346035553Spatrick 84446035553Spatricktemplate <size_t _Size> 84546035553Spatrickinline 846*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 84746035553Spatrickbitset<_Size>& 84846035553Spatrickbitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT 84946035553Spatrick{ 85046035553Spatrick base::operator|=(__rhs); 85146035553Spatrick return *this; 85246035553Spatrick} 85346035553Spatrick 85446035553Spatricktemplate <size_t _Size> 85546035553Spatrickinline 856*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 85746035553Spatrickbitset<_Size>& 85846035553Spatrickbitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT 85946035553Spatrick{ 86046035553Spatrick base::operator^=(__rhs); 86146035553Spatrick return *this; 86246035553Spatrick} 86346035553Spatrick 86446035553Spatricktemplate <size_t _Size> 865*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 86646035553Spatrickbitset<_Size>& 86746035553Spatrickbitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT 86846035553Spatrick{ 86946035553Spatrick __pos = _VSTD::min(__pos, _Size); 87046035553Spatrick _VSTD::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size)); 87146035553Spatrick _VSTD::fill_n(base::__make_iter(0), __pos, false); 87246035553Spatrick return *this; 87346035553Spatrick} 87446035553Spatrick 87546035553Spatricktemplate <size_t _Size> 876*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 87746035553Spatrickbitset<_Size>& 87846035553Spatrickbitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT 87946035553Spatrick{ 88046035553Spatrick __pos = _VSTD::min(__pos, _Size); 88146035553Spatrick _VSTD::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0)); 88246035553Spatrick _VSTD::fill_n(base::__make_iter(_Size - __pos), __pos, false); 88346035553Spatrick return *this; 88446035553Spatrick} 88546035553Spatrick 88646035553Spatricktemplate <size_t _Size> 88746035553Spatrickinline 888*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 88946035553Spatrickbitset<_Size>& 89046035553Spatrickbitset<_Size>::set() _NOEXCEPT 89146035553Spatrick{ 89246035553Spatrick _VSTD::fill_n(base::__make_iter(0), _Size, true); 89346035553Spatrick return *this; 89446035553Spatrick} 89546035553Spatrick 89646035553Spatricktemplate <size_t _Size> 897*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 89846035553Spatrickbitset<_Size>& 89946035553Spatrickbitset<_Size>::set(size_t __pos, bool __val) 90046035553Spatrick{ 90146035553Spatrick if (__pos >= _Size) 90246035553Spatrick __throw_out_of_range("bitset set argument out of range"); 90346035553Spatrick 90446035553Spatrick (*this)[__pos] = __val; 90546035553Spatrick return *this; 90646035553Spatrick} 90746035553Spatrick 90846035553Spatricktemplate <size_t _Size> 90946035553Spatrickinline 910*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 91146035553Spatrickbitset<_Size>& 91246035553Spatrickbitset<_Size>::reset() _NOEXCEPT 91346035553Spatrick{ 91446035553Spatrick _VSTD::fill_n(base::__make_iter(0), _Size, false); 91546035553Spatrick return *this; 91646035553Spatrick} 91746035553Spatrick 91846035553Spatricktemplate <size_t _Size> 919*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 92046035553Spatrickbitset<_Size>& 92146035553Spatrickbitset<_Size>::reset(size_t __pos) 92246035553Spatrick{ 92346035553Spatrick if (__pos >= _Size) 92446035553Spatrick __throw_out_of_range("bitset reset argument out of range"); 92546035553Spatrick 92646035553Spatrick (*this)[__pos] = false; 92746035553Spatrick return *this; 92846035553Spatrick} 92946035553Spatrick 93046035553Spatricktemplate <size_t _Size> 93146035553Spatrickinline 932*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 93346035553Spatrickbitset<_Size> 93446035553Spatrickbitset<_Size>::operator~() const _NOEXCEPT 93546035553Spatrick{ 93646035553Spatrick bitset __x(*this); 93746035553Spatrick __x.flip(); 93846035553Spatrick return __x; 93946035553Spatrick} 94046035553Spatrick 94146035553Spatricktemplate <size_t _Size> 94246035553Spatrickinline 943*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 94446035553Spatrickbitset<_Size>& 94546035553Spatrickbitset<_Size>::flip() _NOEXCEPT 94646035553Spatrick{ 94746035553Spatrick base::flip(); 94846035553Spatrick return *this; 94946035553Spatrick} 95046035553Spatrick 95146035553Spatricktemplate <size_t _Size> 952*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 95346035553Spatrickbitset<_Size>& 95446035553Spatrickbitset<_Size>::flip(size_t __pos) 95546035553Spatrick{ 95646035553Spatrick if (__pos >= _Size) 95746035553Spatrick __throw_out_of_range("bitset flip argument out of range"); 95846035553Spatrick 95946035553Spatrick reference r = base::__make_ref(__pos); 96046035553Spatrick r = ~r; 96146035553Spatrick return *this; 96246035553Spatrick} 96346035553Spatrick 96446035553Spatricktemplate <size_t _Size> 96546035553Spatrickinline 966*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 96746035553Spatrickunsigned long 96846035553Spatrickbitset<_Size>::to_ulong() const 96946035553Spatrick{ 97046035553Spatrick return base::to_ulong(); 97146035553Spatrick} 97246035553Spatrick 97346035553Spatricktemplate <size_t _Size> 97446035553Spatrickinline 975*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 97646035553Spatrickunsigned long long 97746035553Spatrickbitset<_Size>::to_ullong() const 97846035553Spatrick{ 97946035553Spatrick return base::to_ullong(); 98046035553Spatrick} 98146035553Spatrick 98246035553Spatricktemplate <size_t _Size> 98346035553Spatricktemplate <class _CharT, class _Traits, class _Allocator> 984*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 98546035553Spatrickbasic_string<_CharT, _Traits, _Allocator> 98646035553Spatrickbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 98746035553Spatrick{ 98846035553Spatrick basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero); 989*4bdff4beSrobert for (size_t __i = 0; __i != _Size; ++__i) 99046035553Spatrick { 99146035553Spatrick if ((*this)[__i]) 99246035553Spatrick __r[_Size - 1 - __i] = __one; 99346035553Spatrick } 99446035553Spatrick return __r; 99546035553Spatrick} 99646035553Spatrick 99746035553Spatricktemplate <size_t _Size> 99846035553Spatricktemplate <class _CharT, class _Traits> 99946035553Spatrickinline 1000*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 100146035553Spatrickbasic_string<_CharT, _Traits, allocator<_CharT> > 100246035553Spatrickbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 100346035553Spatrick{ 100446035553Spatrick return to_string<_CharT, _Traits, allocator<_CharT> >(__zero, __one); 100546035553Spatrick} 100646035553Spatrick 100746035553Spatricktemplate <size_t _Size> 100846035553Spatricktemplate <class _CharT> 100946035553Spatrickinline 1010*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 101146035553Spatrickbasic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > 101246035553Spatrickbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 101346035553Spatrick{ 101446035553Spatrick return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(__zero, __one); 101546035553Spatrick} 101646035553Spatrick 101746035553Spatricktemplate <size_t _Size> 101846035553Spatrickinline 1019*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 102046035553Spatrickbasic_string<char, char_traits<char>, allocator<char> > 102146035553Spatrickbitset<_Size>::to_string(char __zero, char __one) const 102246035553Spatrick{ 102346035553Spatrick return to_string<char, char_traits<char>, allocator<char> >(__zero, __one); 102446035553Spatrick} 102546035553Spatrick 102646035553Spatricktemplate <size_t _Size> 102746035553Spatrickinline 1028*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 102946035553Spatricksize_t 103046035553Spatrickbitset<_Size>::count() const _NOEXCEPT 103146035553Spatrick{ 103276d0caaeSpatrick return static_cast<size_t>(_VSTD::__count_bool_true(base::__make_iter(0), _Size)); 103346035553Spatrick} 103446035553Spatrick 103546035553Spatricktemplate <size_t _Size> 103646035553Spatrickinline 1037*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 103846035553Spatrickbool 103946035553Spatrickbitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT 104046035553Spatrick{ 104146035553Spatrick return _VSTD::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0)); 104246035553Spatrick} 104346035553Spatrick 104446035553Spatricktemplate <size_t _Size> 104546035553Spatrickinline 1046*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 104746035553Spatrickbool 104846035553Spatrickbitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT 104946035553Spatrick{ 105046035553Spatrick return !(*this == __rhs); 105146035553Spatrick} 105246035553Spatrick 105346035553Spatricktemplate <size_t _Size> 1054*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 105546035553Spatrickbool 105646035553Spatrickbitset<_Size>::test(size_t __pos) const 105746035553Spatrick{ 105846035553Spatrick if (__pos >= _Size) 105946035553Spatrick __throw_out_of_range("bitset test argument out of range"); 106046035553Spatrick 106146035553Spatrick return (*this)[__pos]; 106246035553Spatrick} 106346035553Spatrick 106446035553Spatricktemplate <size_t _Size> 106546035553Spatrickinline 1066*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 106746035553Spatrickbool 106846035553Spatrickbitset<_Size>::all() const _NOEXCEPT 106946035553Spatrick{ 107046035553Spatrick return base::all(); 107146035553Spatrick} 107246035553Spatrick 107346035553Spatricktemplate <size_t _Size> 107446035553Spatrickinline 1075*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 107646035553Spatrickbool 107746035553Spatrickbitset<_Size>::any() const _NOEXCEPT 107846035553Spatrick{ 107946035553Spatrick return base::any(); 108046035553Spatrick} 108146035553Spatrick 108246035553Spatricktemplate <size_t _Size> 108346035553Spatrickinline 1084*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 108546035553Spatrickbitset<_Size> 108646035553Spatrickbitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT 108746035553Spatrick{ 108846035553Spatrick bitset __r = *this; 108946035553Spatrick __r <<= __pos; 109046035553Spatrick return __r; 109146035553Spatrick} 109246035553Spatrick 109346035553Spatricktemplate <size_t _Size> 109446035553Spatrickinline 1095*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 109646035553Spatrickbitset<_Size> 109746035553Spatrickbitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT 109846035553Spatrick{ 109946035553Spatrick bitset __r = *this; 110046035553Spatrick __r >>= __pos; 110146035553Spatrick return __r; 110246035553Spatrick} 110346035553Spatrick 110446035553Spatricktemplate <size_t _Size> 1105*4bdff4beSrobertinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 110646035553Spatrickbitset<_Size> 110746035553Spatrickoperator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 110846035553Spatrick{ 110946035553Spatrick bitset<_Size> __r = __x; 111046035553Spatrick __r &= __y; 111146035553Spatrick return __r; 111246035553Spatrick} 111346035553Spatrick 111446035553Spatricktemplate <size_t _Size> 1115*4bdff4beSrobertinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 111646035553Spatrickbitset<_Size> 111746035553Spatrickoperator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 111846035553Spatrick{ 111946035553Spatrick bitset<_Size> __r = __x; 112046035553Spatrick __r |= __y; 112146035553Spatrick return __r; 112246035553Spatrick} 112346035553Spatrick 112446035553Spatricktemplate <size_t _Size> 1125*4bdff4beSrobertinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 112646035553Spatrickbitset<_Size> 112746035553Spatrickoperator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 112846035553Spatrick{ 112946035553Spatrick bitset<_Size> __r = __x; 113046035553Spatrick __r ^= __y; 113146035553Spatrick return __r; 113246035553Spatrick} 113346035553Spatrick 113446035553Spatricktemplate <size_t _Size> 113546035553Spatrickstruct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> > 1136*4bdff4beSrobert : public __unary_function<bitset<_Size>, size_t> 113746035553Spatrick{ 113846035553Spatrick _LIBCPP_INLINE_VISIBILITY 113946035553Spatrick size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT 114046035553Spatrick {return __bs.__hash_code();} 114146035553Spatrick}; 114246035553Spatrick 114346035553Spatricktemplate <class _CharT, class _Traits, size_t _Size> 1144*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& 114546035553Spatrickoperator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x); 114646035553Spatrick 114746035553Spatricktemplate <class _CharT, class _Traits, size_t _Size> 1148*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& 114946035553Spatrickoperator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x); 115046035553Spatrick 115146035553Spatrick_LIBCPP_END_NAMESPACE_STD 115246035553Spatrick 115346035553Spatrick_LIBCPP_POP_MACROS 115446035553Spatrick 1155*4bdff4beSrobert#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 1156*4bdff4beSrobert# include <concepts> 1157*4bdff4beSrobert#endif 1158*4bdff4beSrobert 115946035553Spatrick#endif // _LIBCPP_BITSET 1160