1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*- 2*58b9f456SAndroid Build Coastguard Worker//===---------------------------- bitset ----------------------------------===// 3*58b9f456SAndroid Build Coastguard Worker// 4*58b9f456SAndroid Build Coastguard Worker// The LLVM Compiler Infrastructure 5*58b9f456SAndroid Build Coastguard Worker// 6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open 7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details. 8*58b9f456SAndroid Build Coastguard Worker// 9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 10*58b9f456SAndroid Build Coastguard Worker 11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_BITSET 12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_BITSET 13*58b9f456SAndroid Build Coastguard Worker 14*58b9f456SAndroid Build Coastguard Worker/* 15*58b9f456SAndroid Build Coastguard Worker bitset synopsis 16*58b9f456SAndroid Build Coastguard Worker 17*58b9f456SAndroid Build Coastguard Workernamespace std 18*58b9f456SAndroid Build Coastguard Worker{ 19*58b9f456SAndroid Build Coastguard Worker 20*58b9f456SAndroid Build Coastguard Workernamespace std { 21*58b9f456SAndroid Build Coastguard Worker 22*58b9f456SAndroid Build Coastguard Workertemplate <size_t N> 23*58b9f456SAndroid Build Coastguard Workerclass bitset 24*58b9f456SAndroid Build Coastguard Worker{ 25*58b9f456SAndroid Build Coastguard Workerpublic: 26*58b9f456SAndroid Build Coastguard Worker // bit reference: 27*58b9f456SAndroid Build Coastguard Worker class reference 28*58b9f456SAndroid Build Coastguard Worker { 29*58b9f456SAndroid Build Coastguard Worker friend class bitset; 30*58b9f456SAndroid Build Coastguard Worker reference() noexcept; 31*58b9f456SAndroid Build Coastguard Worker public: 32*58b9f456SAndroid Build Coastguard Worker ~reference() noexcept; 33*58b9f456SAndroid Build Coastguard Worker reference& operator=(bool x) noexcept; // for b[i] = x; 34*58b9f456SAndroid Build Coastguard Worker reference& operator=(const reference&) noexcept; // for b[i] = b[j]; 35*58b9f456SAndroid Build Coastguard Worker bool operator~() const noexcept; // flips the bit 36*58b9f456SAndroid Build Coastguard Worker operator bool() const noexcept; // for x = b[i]; 37*58b9f456SAndroid Build Coastguard Worker reference& flip() noexcept; // for b[i].flip(); 38*58b9f456SAndroid Build Coastguard Worker }; 39*58b9f456SAndroid Build Coastguard Worker 40*58b9f456SAndroid Build Coastguard Worker // 23.3.5.1 constructors: 41*58b9f456SAndroid Build Coastguard Worker constexpr bitset() noexcept; 42*58b9f456SAndroid Build Coastguard Worker constexpr bitset(unsigned long long val) noexcept; 43*58b9f456SAndroid Build Coastguard Worker template <class charT> 44*58b9f456SAndroid Build Coastguard Worker explicit bitset(const charT* str, 45*58b9f456SAndroid Build Coastguard Worker typename basic_string<charT>::size_type n = basic_string<charT>::npos, 46*58b9f456SAndroid Build Coastguard Worker charT zero = charT('0'), charT one = charT('1')); 47*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits, class Allocator> 48*58b9f456SAndroid Build Coastguard Worker explicit bitset(const basic_string<charT,traits,Allocator>& str, 49*58b9f456SAndroid Build Coastguard Worker typename basic_string<charT,traits,Allocator>::size_type pos = 0, 50*58b9f456SAndroid Build Coastguard Worker typename basic_string<charT,traits,Allocator>::size_type n = 51*58b9f456SAndroid Build Coastguard Worker basic_string<charT,traits,Allocator>::npos, 52*58b9f456SAndroid Build Coastguard Worker charT zero = charT('0'), charT one = charT('1')); 53*58b9f456SAndroid Build Coastguard Worker 54*58b9f456SAndroid Build Coastguard Worker // 23.3.5.2 bitset operations: 55*58b9f456SAndroid Build Coastguard Worker bitset& operator&=(const bitset& rhs) noexcept; 56*58b9f456SAndroid Build Coastguard Worker bitset& operator|=(const bitset& rhs) noexcept; 57*58b9f456SAndroid Build Coastguard Worker bitset& operator^=(const bitset& rhs) noexcept; 58*58b9f456SAndroid Build Coastguard Worker bitset& operator<<=(size_t pos) noexcept; 59*58b9f456SAndroid Build Coastguard Worker bitset& operator>>=(size_t pos) noexcept; 60*58b9f456SAndroid Build Coastguard Worker bitset& set() noexcept; 61*58b9f456SAndroid Build Coastguard Worker bitset& set(size_t pos, bool val = true); 62*58b9f456SAndroid Build Coastguard Worker bitset& reset() noexcept; 63*58b9f456SAndroid Build Coastguard Worker bitset& reset(size_t pos); 64*58b9f456SAndroid Build Coastguard Worker bitset operator~() const noexcept; 65*58b9f456SAndroid Build Coastguard Worker bitset& flip() noexcept; 66*58b9f456SAndroid Build Coastguard Worker bitset& flip(size_t pos); 67*58b9f456SAndroid Build Coastguard Worker 68*58b9f456SAndroid Build Coastguard Worker // element access: 69*58b9f456SAndroid Build Coastguard Worker constexpr bool operator[](size_t pos) const; // for b[i]; 70*58b9f456SAndroid Build Coastguard Worker reference operator[](size_t pos); // for b[i]; 71*58b9f456SAndroid Build Coastguard Worker unsigned long to_ulong() const; 72*58b9f456SAndroid Build Coastguard Worker unsigned long long to_ullong() const; 73*58b9f456SAndroid Build Coastguard Worker template <class charT, class traits, class Allocator> 74*58b9f456SAndroid Build Coastguard Worker basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const; 75*58b9f456SAndroid Build Coastguard Worker template <class charT, class traits> 76*58b9f456SAndroid Build Coastguard Worker basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const; 77*58b9f456SAndroid Build Coastguard Worker template <class charT> 78*58b9f456SAndroid Build Coastguard Worker basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const; 79*58b9f456SAndroid Build Coastguard Worker basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const; 80*58b9f456SAndroid Build Coastguard Worker size_t count() const noexcept; 81*58b9f456SAndroid Build Coastguard Worker constexpr size_t size() const noexcept; 82*58b9f456SAndroid Build Coastguard Worker bool operator==(const bitset& rhs) const noexcept; 83*58b9f456SAndroid Build Coastguard Worker bool operator!=(const bitset& rhs) const noexcept; 84*58b9f456SAndroid Build Coastguard Worker bool test(size_t pos) const; 85*58b9f456SAndroid Build Coastguard Worker bool all() const noexcept; 86*58b9f456SAndroid Build Coastguard Worker bool any() const noexcept; 87*58b9f456SAndroid Build Coastguard Worker bool none() const noexcept; 88*58b9f456SAndroid Build Coastguard Worker bitset operator<<(size_t pos) const noexcept; 89*58b9f456SAndroid Build Coastguard Worker bitset operator>>(size_t pos) const noexcept; 90*58b9f456SAndroid Build Coastguard Worker}; 91*58b9f456SAndroid Build Coastguard Worker 92*58b9f456SAndroid Build Coastguard Worker// 23.3.5.3 bitset operators: 93*58b9f456SAndroid Build Coastguard Workertemplate <size_t N> 94*58b9f456SAndroid Build Coastguard Workerbitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept; 95*58b9f456SAndroid Build Coastguard Worker 96*58b9f456SAndroid Build Coastguard Workertemplate <size_t N> 97*58b9f456SAndroid Build Coastguard Workerbitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept; 98*58b9f456SAndroid Build Coastguard Worker 99*58b9f456SAndroid Build Coastguard Workertemplate <size_t N> 100*58b9f456SAndroid Build Coastguard Workerbitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept; 101*58b9f456SAndroid Build Coastguard Worker 102*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits, size_t N> 103*58b9f456SAndroid Build Coastguard Workerbasic_istream<charT, traits>& 104*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<charT, traits>& is, bitset<N>& x); 105*58b9f456SAndroid Build Coastguard Worker 106*58b9f456SAndroid Build Coastguard Workertemplate <class charT, class traits, size_t N> 107*58b9f456SAndroid Build Coastguard Workerbasic_ostream<charT, traits>& 108*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<charT, traits>& os, const bitset<N>& x); 109*58b9f456SAndroid Build Coastguard Worker 110*58b9f456SAndroid Build Coastguard Workertemplate <size_t N> struct hash<std::bitset<N>>; 111*58b9f456SAndroid Build Coastguard Worker 112*58b9f456SAndroid Build Coastguard Worker} // std 113*58b9f456SAndroid Build Coastguard Worker 114*58b9f456SAndroid Build Coastguard Worker*/ 115*58b9f456SAndroid Build Coastguard Worker 116*58b9f456SAndroid Build Coastguard Worker#include <__config> 117*58b9f456SAndroid Build Coastguard Worker#include <__bit_reference> 118*58b9f456SAndroid Build Coastguard Worker#include <cstddef> 119*58b9f456SAndroid Build Coastguard Worker#include <climits> 120*58b9f456SAndroid Build Coastguard Worker#include <string> 121*58b9f456SAndroid Build Coastguard Worker#include <stdexcept> 122*58b9f456SAndroid Build Coastguard Worker#include <iosfwd> 123*58b9f456SAndroid Build Coastguard Worker#include <__functional_base> 124*58b9f456SAndroid Build Coastguard Worker 125*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 126*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header 127*58b9f456SAndroid Build Coastguard Worker#endif 128*58b9f456SAndroid Build Coastguard Worker 129*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS 130*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros> 131*58b9f456SAndroid Build Coastguard Worker 132*58b9f456SAndroid Build Coastguard Worker 133*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD 134*58b9f456SAndroid Build Coastguard Worker 135*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 136*58b9f456SAndroid Build Coastguard Workerclass __bitset; 137*58b9f456SAndroid Build Coastguard Worker 138*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 139*58b9f456SAndroid Build Coastguard Workerstruct __has_storage_type<__bitset<_N_words, _Size> > 140*58b9f456SAndroid Build Coastguard Worker{ 141*58b9f456SAndroid Build Coastguard Worker static const bool value = true; 142*58b9f456SAndroid Build Coastguard Worker}; 143*58b9f456SAndroid Build Coastguard Worker 144*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 145*58b9f456SAndroid Build Coastguard Workerclass __bitset 146*58b9f456SAndroid Build Coastguard Worker{ 147*58b9f456SAndroid Build Coastguard Workerpublic: 148*58b9f456SAndroid Build Coastguard Worker typedef ptrdiff_t difference_type; 149*58b9f456SAndroid Build Coastguard Worker typedef size_t size_type; 150*58b9f456SAndroid Build Coastguard Worker typedef size_type __storage_type; 151*58b9f456SAndroid Build Coastguard Workerprotected: 152*58b9f456SAndroid Build Coastguard Worker typedef __bitset __self; 153*58b9f456SAndroid Build Coastguard Worker typedef __storage_type* __storage_pointer; 154*58b9f456SAndroid Build Coastguard Worker typedef const __storage_type* __const_storage_pointer; 155*58b9f456SAndroid Build Coastguard Worker static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 156*58b9f456SAndroid Build Coastguard Worker 157*58b9f456SAndroid Build Coastguard Worker friend class __bit_reference<__bitset>; 158*58b9f456SAndroid Build Coastguard Worker friend class __bit_const_reference<__bitset>; 159*58b9f456SAndroid Build Coastguard Worker friend class __bit_iterator<__bitset, false>; 160*58b9f456SAndroid Build Coastguard Worker friend class __bit_iterator<__bitset, true>; 161*58b9f456SAndroid Build Coastguard Worker friend struct __bit_array<__bitset>; 162*58b9f456SAndroid Build Coastguard Worker 163*58b9f456SAndroid Build Coastguard Worker __storage_type __first_[_N_words]; 164*58b9f456SAndroid Build Coastguard Worker 165*58b9f456SAndroid Build Coastguard Worker typedef __bit_reference<__bitset> reference; 166*58b9f456SAndroid Build Coastguard Worker typedef __bit_const_reference<__bitset> const_reference; 167*58b9f456SAndroid Build Coastguard Worker typedef __bit_iterator<__bitset, false> iterator; 168*58b9f456SAndroid Build Coastguard Worker typedef __bit_iterator<__bitset, true> const_iterator; 169*58b9f456SAndroid Build Coastguard Worker 170*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 171*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 172*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 173*58b9f456SAndroid Build Coastguard Worker explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; 174*58b9f456SAndroid Build Coastguard Worker 175*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT 176*58b9f456SAndroid Build Coastguard Worker {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} 177*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT 178*58b9f456SAndroid Build Coastguard Worker {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} 179*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT 180*58b9f456SAndroid Build Coastguard Worker {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 181*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT 182*58b9f456SAndroid Build Coastguard Worker {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 183*58b9f456SAndroid Build Coastguard Worker 184*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 185*58b9f456SAndroid Build Coastguard Worker void operator&=(const __bitset& __v) _NOEXCEPT; 186*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 187*58b9f456SAndroid Build Coastguard Worker void operator|=(const __bitset& __v) _NOEXCEPT; 188*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 189*58b9f456SAndroid Build Coastguard Worker void operator^=(const __bitset& __v) _NOEXCEPT; 190*58b9f456SAndroid Build Coastguard Worker 191*58b9f456SAndroid Build Coastguard Worker void flip() _NOEXCEPT; 192*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const 193*58b9f456SAndroid Build Coastguard Worker {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());} 194*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const 195*58b9f456SAndroid Build Coastguard Worker {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());} 196*58b9f456SAndroid Build Coastguard Worker 197*58b9f456SAndroid Build Coastguard Worker bool all() const _NOEXCEPT; 198*58b9f456SAndroid Build Coastguard Worker bool any() const _NOEXCEPT; 199*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 200*58b9f456SAndroid Build Coastguard Worker size_t __hash_code() const _NOEXCEPT; 201*58b9f456SAndroid Build Coastguard Workerprivate: 202*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_CXX03_LANG 203*58b9f456SAndroid Build Coastguard Worker void __init(unsigned long long __v, false_type) _NOEXCEPT; 204*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 205*58b9f456SAndroid Build Coastguard Worker void __init(unsigned long long __v, true_type) _NOEXCEPT; 206*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_CXX03_LANG 207*58b9f456SAndroid Build Coastguard Worker unsigned long to_ulong(false_type) const; 208*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 209*58b9f456SAndroid Build Coastguard Worker unsigned long to_ulong(true_type) const; 210*58b9f456SAndroid Build Coastguard Worker unsigned long long to_ullong(false_type) const; 211*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 212*58b9f456SAndroid Build Coastguard Worker unsigned long long to_ullong(true_type) const; 213*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 214*58b9f456SAndroid Build Coastguard Worker unsigned long long to_ullong(true_type, false_type) const; 215*58b9f456SAndroid Build Coastguard Worker unsigned long long to_ullong(true_type, true_type) const; 216*58b9f456SAndroid Build Coastguard Worker}; 217*58b9f456SAndroid Build Coastguard Worker 218*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 219*58b9f456SAndroid Build Coastguard Workerinline 220*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR 221*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::__bitset() _NOEXCEPT 222*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 223*58b9f456SAndroid Build Coastguard Worker : __first_{0} 224*58b9f456SAndroid Build Coastguard Worker#endif 225*58b9f456SAndroid Build Coastguard Worker{ 226*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_CXX03_LANG 227*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(__first_, _N_words, __storage_type(0)); 228*58b9f456SAndroid Build Coastguard Worker#endif 229*58b9f456SAndroid Build Coastguard Worker} 230*58b9f456SAndroid Build Coastguard Worker 231*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_CXX03_LANG 232*58b9f456SAndroid Build Coastguard Worker 233*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 234*58b9f456SAndroid Build Coastguard Workervoid 235*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT 236*58b9f456SAndroid Build Coastguard Worker{ 237*58b9f456SAndroid Build Coastguard Worker __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)]; 238*58b9f456SAndroid Build Coastguard Worker size_t __sz = _Size; 239*58b9f456SAndroid Build Coastguard Worker for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word ) 240*58b9f456SAndroid Build Coastguard Worker if ( __sz < __bits_per_word) 241*58b9f456SAndroid Build Coastguard Worker __t[__i] = static_cast<__storage_type>(__v) & ( 1ULL << __sz ) - 1; 242*58b9f456SAndroid Build Coastguard Worker else 243*58b9f456SAndroid Build Coastguard Worker __t[__i] = static_cast<__storage_type>(__v); 244*58b9f456SAndroid Build Coastguard Worker 245*58b9f456SAndroid Build Coastguard Worker _VSTD::copy(__t, __t + sizeof(__t)/sizeof(__t[0]), __first_); 246*58b9f456SAndroid Build Coastguard Worker _VSTD::fill(__first_ + sizeof(__t)/sizeof(__t[0]), __first_ + sizeof(__first_)/sizeof(__first_[0]), 247*58b9f456SAndroid Build Coastguard Worker __storage_type(0)); 248*58b9f456SAndroid Build Coastguard Worker} 249*58b9f456SAndroid Build Coastguard Worker 250*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 251*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 252*58b9f456SAndroid Build Coastguard Workervoid 253*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT 254*58b9f456SAndroid Build Coastguard Worker{ 255*58b9f456SAndroid Build Coastguard Worker __first_[0] = __v; 256*58b9f456SAndroid Build Coastguard Worker if (_Size < __bits_per_word) 257*58b9f456SAndroid Build Coastguard Worker __first_[0] &= ( 1ULL << _Size ) - 1; 258*58b9f456SAndroid Build Coastguard Worker 259*58b9f456SAndroid Build Coastguard Worker _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0)); 260*58b9f456SAndroid Build Coastguard Worker} 261*58b9f456SAndroid Build Coastguard Worker 262*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_CXX03_LANG 263*58b9f456SAndroid Build Coastguard Worker 264*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 265*58b9f456SAndroid Build Coastguard Workerinline 266*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR 267*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT 268*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG 269*58b9f456SAndroid Build Coastguard Worker#if __SIZEOF_SIZE_T__ == 8 270*58b9f456SAndroid Build Coastguard Worker : __first_{__v} 271*58b9f456SAndroid Build Coastguard Worker#elif __SIZEOF_SIZE_T__ == 4 272*58b9f456SAndroid Build Coastguard Worker : __first_{static_cast<__storage_type>(__v), 273*58b9f456SAndroid Build Coastguard Worker _Size >= 2 * __bits_per_word ? static_cast<__storage_type>(__v >> __bits_per_word) 274*58b9f456SAndroid Build Coastguard Worker : static_cast<__storage_type>((__v >> __bits_per_word) & (__storage_type(1) << (_Size - __bits_per_word)) - 1)} 275*58b9f456SAndroid Build Coastguard Worker#else 276*58b9f456SAndroid Build Coastguard Worker#error This constructor has not been ported to this platform 277*58b9f456SAndroid Build Coastguard Worker#endif 278*58b9f456SAndroid Build Coastguard Worker#endif 279*58b9f456SAndroid Build Coastguard Worker{ 280*58b9f456SAndroid Build Coastguard Worker#ifdef _LIBCPP_CXX03_LANG 281*58b9f456SAndroid Build Coastguard Worker __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>()); 282*58b9f456SAndroid Build Coastguard Worker#endif 283*58b9f456SAndroid Build Coastguard Worker} 284*58b9f456SAndroid Build Coastguard Worker 285*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 286*58b9f456SAndroid Build Coastguard Workerinline 287*58b9f456SAndroid Build Coastguard Workervoid 288*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT 289*58b9f456SAndroid Build Coastguard Worker{ 290*58b9f456SAndroid Build Coastguard Worker for (size_type __i = 0; __i < _N_words; ++__i) 291*58b9f456SAndroid Build Coastguard Worker __first_[__i] &= __v.__first_[__i]; 292*58b9f456SAndroid Build Coastguard Worker} 293*58b9f456SAndroid Build Coastguard Worker 294*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 295*58b9f456SAndroid Build Coastguard Workerinline 296*58b9f456SAndroid Build Coastguard Workervoid 297*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT 298*58b9f456SAndroid Build Coastguard Worker{ 299*58b9f456SAndroid Build Coastguard Worker for (size_type __i = 0; __i < _N_words; ++__i) 300*58b9f456SAndroid Build Coastguard Worker __first_[__i] |= __v.__first_[__i]; 301*58b9f456SAndroid Build Coastguard Worker} 302*58b9f456SAndroid Build Coastguard Worker 303*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 304*58b9f456SAndroid Build Coastguard Workerinline 305*58b9f456SAndroid Build Coastguard Workervoid 306*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT 307*58b9f456SAndroid Build Coastguard Worker{ 308*58b9f456SAndroid Build Coastguard Worker for (size_type __i = 0; __i < _N_words; ++__i) 309*58b9f456SAndroid Build Coastguard Worker __first_[__i] ^= __v.__first_[__i]; 310*58b9f456SAndroid Build Coastguard Worker} 311*58b9f456SAndroid Build Coastguard Worker 312*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 313*58b9f456SAndroid Build Coastguard Workervoid 314*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::flip() _NOEXCEPT 315*58b9f456SAndroid Build Coastguard Worker{ 316*58b9f456SAndroid Build Coastguard Worker // do middle whole words 317*58b9f456SAndroid Build Coastguard Worker size_type __n = _Size; 318*58b9f456SAndroid Build Coastguard Worker __storage_pointer __p = __first_; 319*58b9f456SAndroid Build Coastguard Worker for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 320*58b9f456SAndroid Build Coastguard Worker *__p = ~*__p; 321*58b9f456SAndroid Build Coastguard Worker // do last partial word 322*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 323*58b9f456SAndroid Build Coastguard Worker { 324*58b9f456SAndroid Build Coastguard Worker __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 325*58b9f456SAndroid Build Coastguard Worker __storage_type __b = *__p & __m; 326*58b9f456SAndroid Build Coastguard Worker *__p &= ~__m; 327*58b9f456SAndroid Build Coastguard Worker *__p |= ~__b & __m; 328*58b9f456SAndroid Build Coastguard Worker } 329*58b9f456SAndroid Build Coastguard Worker} 330*58b9f456SAndroid Build Coastguard Worker 331*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 332*58b9f456SAndroid Build Coastguard Workerunsigned long 333*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::to_ulong(false_type) const 334*58b9f456SAndroid Build Coastguard Worker{ 335*58b9f456SAndroid Build Coastguard Worker const_iterator __e = __make_iter(_Size); 336*58b9f456SAndroid Build Coastguard Worker const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true); 337*58b9f456SAndroid Build Coastguard Worker if (__i != __e) 338*58b9f456SAndroid Build Coastguard Worker __throw_overflow_error("bitset to_ulong overflow error"); 339*58b9f456SAndroid Build Coastguard Worker 340*58b9f456SAndroid Build Coastguard Worker return __first_[0]; 341*58b9f456SAndroid Build Coastguard Worker} 342*58b9f456SAndroid Build Coastguard Worker 343*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 344*58b9f456SAndroid Build Coastguard Workerinline 345*58b9f456SAndroid Build Coastguard Workerunsigned long 346*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::to_ulong(true_type) const 347*58b9f456SAndroid Build Coastguard Worker{ 348*58b9f456SAndroid Build Coastguard Worker return __first_[0]; 349*58b9f456SAndroid Build Coastguard Worker} 350*58b9f456SAndroid Build Coastguard Worker 351*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 352*58b9f456SAndroid Build Coastguard Workerunsigned long long 353*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::to_ullong(false_type) const 354*58b9f456SAndroid Build Coastguard Worker{ 355*58b9f456SAndroid Build Coastguard Worker const_iterator __e = __make_iter(_Size); 356*58b9f456SAndroid Build Coastguard Worker const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true); 357*58b9f456SAndroid Build Coastguard Worker if (__i != __e) 358*58b9f456SAndroid Build Coastguard Worker __throw_overflow_error("bitset to_ullong overflow error"); 359*58b9f456SAndroid Build Coastguard Worker 360*58b9f456SAndroid Build Coastguard Worker return to_ullong(true_type()); 361*58b9f456SAndroid Build Coastguard Worker} 362*58b9f456SAndroid Build Coastguard Worker 363*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 364*58b9f456SAndroid Build Coastguard Workerinline 365*58b9f456SAndroid Build Coastguard Workerunsigned long long 366*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::to_ullong(true_type) const 367*58b9f456SAndroid Build Coastguard Worker{ 368*58b9f456SAndroid Build Coastguard Worker return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>()); 369*58b9f456SAndroid Build Coastguard Worker} 370*58b9f456SAndroid Build Coastguard Worker 371*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 372*58b9f456SAndroid Build Coastguard Workerinline 373*58b9f456SAndroid Build Coastguard Workerunsigned long long 374*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const 375*58b9f456SAndroid Build Coastguard Worker{ 376*58b9f456SAndroid Build Coastguard Worker return __first_[0]; 377*58b9f456SAndroid Build Coastguard Worker} 378*58b9f456SAndroid Build Coastguard Worker 379*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 380*58b9f456SAndroid Build Coastguard Workerunsigned long long 381*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const 382*58b9f456SAndroid Build Coastguard Worker{ 383*58b9f456SAndroid Build Coastguard Worker unsigned long long __r = __first_[0]; 384*58b9f456SAndroid Build Coastguard Worker for (std::size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i) 385*58b9f456SAndroid Build Coastguard Worker __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT); 386*58b9f456SAndroid Build Coastguard Worker return __r; 387*58b9f456SAndroid Build Coastguard Worker} 388*58b9f456SAndroid Build Coastguard Worker 389*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 390*58b9f456SAndroid Build Coastguard Workerbool 391*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::all() const _NOEXCEPT 392*58b9f456SAndroid Build Coastguard Worker{ 393*58b9f456SAndroid Build Coastguard Worker // do middle whole words 394*58b9f456SAndroid Build Coastguard Worker size_type __n = _Size; 395*58b9f456SAndroid Build Coastguard Worker __const_storage_pointer __p = __first_; 396*58b9f456SAndroid Build Coastguard Worker for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 397*58b9f456SAndroid Build Coastguard Worker if (~*__p) 398*58b9f456SAndroid Build Coastguard Worker return false; 399*58b9f456SAndroid Build Coastguard Worker // do last partial word 400*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 401*58b9f456SAndroid Build Coastguard Worker { 402*58b9f456SAndroid Build Coastguard Worker __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 403*58b9f456SAndroid Build Coastguard Worker if (~*__p & __m) 404*58b9f456SAndroid Build Coastguard Worker return false; 405*58b9f456SAndroid Build Coastguard Worker } 406*58b9f456SAndroid Build Coastguard Worker return true; 407*58b9f456SAndroid Build Coastguard Worker} 408*58b9f456SAndroid Build Coastguard Worker 409*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 410*58b9f456SAndroid Build Coastguard Workerbool 411*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::any() const _NOEXCEPT 412*58b9f456SAndroid Build Coastguard Worker{ 413*58b9f456SAndroid Build Coastguard Worker // do middle whole words 414*58b9f456SAndroid Build Coastguard Worker size_type __n = _Size; 415*58b9f456SAndroid Build Coastguard Worker __const_storage_pointer __p = __first_; 416*58b9f456SAndroid Build Coastguard Worker for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 417*58b9f456SAndroid Build Coastguard Worker if (*__p) 418*58b9f456SAndroid Build Coastguard Worker return true; 419*58b9f456SAndroid Build Coastguard Worker // do last partial word 420*58b9f456SAndroid Build Coastguard Worker if (__n > 0) 421*58b9f456SAndroid Build Coastguard Worker { 422*58b9f456SAndroid Build Coastguard Worker __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 423*58b9f456SAndroid Build Coastguard Worker if (*__p & __m) 424*58b9f456SAndroid Build Coastguard Worker return true; 425*58b9f456SAndroid Build Coastguard Worker } 426*58b9f456SAndroid Build Coastguard Worker return false; 427*58b9f456SAndroid Build Coastguard Worker} 428*58b9f456SAndroid Build Coastguard Worker 429*58b9f456SAndroid Build Coastguard Workertemplate <size_t _N_words, size_t _Size> 430*58b9f456SAndroid Build Coastguard Workerinline 431*58b9f456SAndroid Build Coastguard Workersize_t 432*58b9f456SAndroid Build Coastguard Worker__bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT 433*58b9f456SAndroid Build Coastguard Worker{ 434*58b9f456SAndroid Build Coastguard Worker size_t __h = 0; 435*58b9f456SAndroid Build Coastguard Worker for (size_type __i = 0; __i < _N_words; ++__i) 436*58b9f456SAndroid Build Coastguard Worker __h ^= __first_[__i]; 437*58b9f456SAndroid Build Coastguard Worker return __h; 438*58b9f456SAndroid Build Coastguard Worker} 439*58b9f456SAndroid Build Coastguard Worker 440*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 441*58b9f456SAndroid Build Coastguard Workerclass __bitset<1, _Size> 442*58b9f456SAndroid Build Coastguard Worker{ 443*58b9f456SAndroid Build Coastguard Workerpublic: 444*58b9f456SAndroid Build Coastguard Worker typedef ptrdiff_t difference_type; 445*58b9f456SAndroid Build Coastguard Worker typedef size_t size_type; 446*58b9f456SAndroid Build Coastguard Worker typedef size_type __storage_type; 447*58b9f456SAndroid Build Coastguard Workerprotected: 448*58b9f456SAndroid Build Coastguard Worker typedef __bitset __self; 449*58b9f456SAndroid Build Coastguard Worker typedef __storage_type* __storage_pointer; 450*58b9f456SAndroid Build Coastguard Worker typedef const __storage_type* __const_storage_pointer; 451*58b9f456SAndroid Build Coastguard Worker static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 452*58b9f456SAndroid Build Coastguard Worker 453*58b9f456SAndroid Build Coastguard Worker friend class __bit_reference<__bitset>; 454*58b9f456SAndroid Build Coastguard Worker friend class __bit_const_reference<__bitset>; 455*58b9f456SAndroid Build Coastguard Worker friend class __bit_iterator<__bitset, false>; 456*58b9f456SAndroid Build Coastguard Worker friend class __bit_iterator<__bitset, true>; 457*58b9f456SAndroid Build Coastguard Worker friend struct __bit_array<__bitset>; 458*58b9f456SAndroid Build Coastguard Worker 459*58b9f456SAndroid Build Coastguard Worker __storage_type __first_; 460*58b9f456SAndroid Build Coastguard Worker 461*58b9f456SAndroid Build Coastguard Worker typedef __bit_reference<__bitset> reference; 462*58b9f456SAndroid Build Coastguard Worker typedef __bit_const_reference<__bitset> const_reference; 463*58b9f456SAndroid Build Coastguard Worker typedef __bit_iterator<__bitset, false> iterator; 464*58b9f456SAndroid Build Coastguard Worker typedef __bit_iterator<__bitset, true> const_iterator; 465*58b9f456SAndroid Build Coastguard Worker 466*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 467*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 468*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 469*58b9f456SAndroid Build Coastguard Worker explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; 470*58b9f456SAndroid Build Coastguard Worker 471*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT 472*58b9f456SAndroid Build Coastguard Worker {return reference(&__first_, __storage_type(1) << __pos);} 473*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT 474*58b9f456SAndroid Build Coastguard Worker {return const_reference(&__first_, __storage_type(1) << __pos);} 475*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT 476*58b9f456SAndroid Build Coastguard Worker {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 477*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT 478*58b9f456SAndroid Build Coastguard Worker {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 479*58b9f456SAndroid Build Coastguard Worker 480*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 481*58b9f456SAndroid Build Coastguard Worker void operator&=(const __bitset& __v) _NOEXCEPT; 482*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 483*58b9f456SAndroid Build Coastguard Worker void operator|=(const __bitset& __v) _NOEXCEPT; 484*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 485*58b9f456SAndroid Build Coastguard Worker void operator^=(const __bitset& __v) _NOEXCEPT; 486*58b9f456SAndroid Build Coastguard Worker 487*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 488*58b9f456SAndroid Build Coastguard Worker void flip() _NOEXCEPT; 489*58b9f456SAndroid Build Coastguard Worker 490*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 491*58b9f456SAndroid Build Coastguard Worker unsigned long to_ulong() const; 492*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 493*58b9f456SAndroid Build Coastguard Worker unsigned long long to_ullong() const; 494*58b9f456SAndroid Build Coastguard Worker 495*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 496*58b9f456SAndroid Build Coastguard Worker bool all() const _NOEXCEPT; 497*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 498*58b9f456SAndroid Build Coastguard Worker bool any() const _NOEXCEPT; 499*58b9f456SAndroid Build Coastguard Worker 500*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 501*58b9f456SAndroid Build Coastguard Worker size_t __hash_code() const _NOEXCEPT; 502*58b9f456SAndroid Build Coastguard Worker}; 503*58b9f456SAndroid Build Coastguard Worker 504*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 505*58b9f456SAndroid Build Coastguard Workerinline 506*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR 507*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::__bitset() _NOEXCEPT 508*58b9f456SAndroid Build Coastguard Worker : __first_(0) 509*58b9f456SAndroid Build Coastguard Worker{ 510*58b9f456SAndroid Build Coastguard Worker} 511*58b9f456SAndroid Build Coastguard Worker 512*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 513*58b9f456SAndroid Build Coastguard Workerinline 514*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR 515*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT 516*58b9f456SAndroid Build Coastguard Worker : __first_( 517*58b9f456SAndroid Build Coastguard Worker _Size == __bits_per_word ? static_cast<__storage_type>(__v) 518*58b9f456SAndroid Build Coastguard Worker : static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1) 519*58b9f456SAndroid Build Coastguard Worker ) 520*58b9f456SAndroid Build Coastguard Worker{ 521*58b9f456SAndroid Build Coastguard Worker} 522*58b9f456SAndroid Build Coastguard Worker 523*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 524*58b9f456SAndroid Build Coastguard Workerinline 525*58b9f456SAndroid Build Coastguard Workervoid 526*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT 527*58b9f456SAndroid Build Coastguard Worker{ 528*58b9f456SAndroid Build Coastguard Worker __first_ &= __v.__first_; 529*58b9f456SAndroid Build Coastguard Worker} 530*58b9f456SAndroid Build Coastguard Worker 531*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 532*58b9f456SAndroid Build Coastguard Workerinline 533*58b9f456SAndroid Build Coastguard Workervoid 534*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT 535*58b9f456SAndroid Build Coastguard Worker{ 536*58b9f456SAndroid Build Coastguard Worker __first_ |= __v.__first_; 537*58b9f456SAndroid Build Coastguard Worker} 538*58b9f456SAndroid Build Coastguard Worker 539*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 540*58b9f456SAndroid Build Coastguard Workerinline 541*58b9f456SAndroid Build Coastguard Workervoid 542*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT 543*58b9f456SAndroid Build Coastguard Worker{ 544*58b9f456SAndroid Build Coastguard Worker __first_ ^= __v.__first_; 545*58b9f456SAndroid Build Coastguard Worker} 546*58b9f456SAndroid Build Coastguard Worker 547*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 548*58b9f456SAndroid Build Coastguard Workerinline 549*58b9f456SAndroid Build Coastguard Workervoid 550*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::flip() _NOEXCEPT 551*58b9f456SAndroid Build Coastguard Worker{ 552*58b9f456SAndroid Build Coastguard Worker __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 553*58b9f456SAndroid Build Coastguard Worker __first_ = ~__first_; 554*58b9f456SAndroid Build Coastguard Worker __first_ &= __m; 555*58b9f456SAndroid Build Coastguard Worker} 556*58b9f456SAndroid Build Coastguard Worker 557*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 558*58b9f456SAndroid Build Coastguard Workerinline 559*58b9f456SAndroid Build Coastguard Workerunsigned long 560*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::to_ulong() const 561*58b9f456SAndroid Build Coastguard Worker{ 562*58b9f456SAndroid Build Coastguard Worker return __first_; 563*58b9f456SAndroid Build Coastguard Worker} 564*58b9f456SAndroid Build Coastguard Worker 565*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 566*58b9f456SAndroid Build Coastguard Workerinline 567*58b9f456SAndroid Build Coastguard Workerunsigned long long 568*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::to_ullong() const 569*58b9f456SAndroid Build Coastguard Worker{ 570*58b9f456SAndroid Build Coastguard Worker return __first_; 571*58b9f456SAndroid Build Coastguard Worker} 572*58b9f456SAndroid Build Coastguard Worker 573*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 574*58b9f456SAndroid Build Coastguard Workerinline 575*58b9f456SAndroid Build Coastguard Workerbool 576*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::all() const _NOEXCEPT 577*58b9f456SAndroid Build Coastguard Worker{ 578*58b9f456SAndroid Build Coastguard Worker __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 579*58b9f456SAndroid Build Coastguard Worker return !(~__first_ & __m); 580*58b9f456SAndroid Build Coastguard Worker} 581*58b9f456SAndroid Build Coastguard Worker 582*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 583*58b9f456SAndroid Build Coastguard Workerinline 584*58b9f456SAndroid Build Coastguard Workerbool 585*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::any() const _NOEXCEPT 586*58b9f456SAndroid Build Coastguard Worker{ 587*58b9f456SAndroid Build Coastguard Worker __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 588*58b9f456SAndroid Build Coastguard Worker return __first_ & __m; 589*58b9f456SAndroid Build Coastguard Worker} 590*58b9f456SAndroid Build Coastguard Worker 591*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 592*58b9f456SAndroid Build Coastguard Workerinline 593*58b9f456SAndroid Build Coastguard Workersize_t 594*58b9f456SAndroid Build Coastguard Worker__bitset<1, _Size>::__hash_code() const _NOEXCEPT 595*58b9f456SAndroid Build Coastguard Worker{ 596*58b9f456SAndroid Build Coastguard Worker return __first_; 597*58b9f456SAndroid Build Coastguard Worker} 598*58b9f456SAndroid Build Coastguard Worker 599*58b9f456SAndroid Build Coastguard Workertemplate <> 600*58b9f456SAndroid Build Coastguard Workerclass __bitset<0, 0> 601*58b9f456SAndroid Build Coastguard Worker{ 602*58b9f456SAndroid Build Coastguard Workerpublic: 603*58b9f456SAndroid Build Coastguard Worker typedef ptrdiff_t difference_type; 604*58b9f456SAndroid Build Coastguard Worker typedef size_t size_type; 605*58b9f456SAndroid Build Coastguard Worker typedef size_type __storage_type; 606*58b9f456SAndroid Build Coastguard Workerprotected: 607*58b9f456SAndroid Build Coastguard Worker typedef __bitset __self; 608*58b9f456SAndroid Build Coastguard Worker typedef __storage_type* __storage_pointer; 609*58b9f456SAndroid Build Coastguard Worker typedef const __storage_type* __const_storage_pointer; 610*58b9f456SAndroid Build Coastguard Worker static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 611*58b9f456SAndroid Build Coastguard Worker 612*58b9f456SAndroid Build Coastguard Worker friend class __bit_reference<__bitset>; 613*58b9f456SAndroid Build Coastguard Worker friend class __bit_const_reference<__bitset>; 614*58b9f456SAndroid Build Coastguard Worker friend class __bit_iterator<__bitset, false>; 615*58b9f456SAndroid Build Coastguard Worker friend class __bit_iterator<__bitset, true>; 616*58b9f456SAndroid Build Coastguard Worker friend struct __bit_array<__bitset>; 617*58b9f456SAndroid Build Coastguard Worker 618*58b9f456SAndroid Build Coastguard Worker typedef __bit_reference<__bitset> reference; 619*58b9f456SAndroid Build Coastguard Worker typedef __bit_const_reference<__bitset> const_reference; 620*58b9f456SAndroid Build Coastguard Worker typedef __bit_iterator<__bitset, false> iterator; 621*58b9f456SAndroid Build Coastguard Worker typedef __bit_iterator<__bitset, true> const_iterator; 622*58b9f456SAndroid Build Coastguard Worker 623*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 624*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 625*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 626*58b9f456SAndroid Build Coastguard Worker explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; 627*58b9f456SAndroid Build Coastguard Worker 628*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT 629*58b9f456SAndroid Build Coastguard Worker {return reference(0, 1);} 630*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT 631*58b9f456SAndroid Build Coastguard Worker {return const_reference(0, 1);} 632*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT 633*58b9f456SAndroid Build Coastguard Worker {return iterator(0, 0);} 634*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT 635*58b9f456SAndroid Build Coastguard Worker {return const_iterator(0, 0);} 636*58b9f456SAndroid Build Coastguard Worker 637*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {} 638*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {} 639*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset&) _NOEXCEPT {} 640*58b9f456SAndroid Build Coastguard Worker 641*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {} 642*58b9f456SAndroid Build Coastguard Worker 643*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const {return 0;} 644*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const {return 0;} 645*58b9f456SAndroid Build Coastguard Worker 646*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT {return true;} 647*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT {return false;} 648*58b9f456SAndroid Build Coastguard Worker 649*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;} 650*58b9f456SAndroid Build Coastguard Worker}; 651*58b9f456SAndroid Build Coastguard Worker 652*58b9f456SAndroid Build Coastguard Workerinline 653*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR 654*58b9f456SAndroid Build Coastguard Worker__bitset<0, 0>::__bitset() _NOEXCEPT 655*58b9f456SAndroid Build Coastguard Worker{ 656*58b9f456SAndroid Build Coastguard Worker} 657*58b9f456SAndroid Build Coastguard Worker 658*58b9f456SAndroid Build Coastguard Workerinline 659*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR 660*58b9f456SAndroid Build Coastguard Worker__bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT 661*58b9f456SAndroid Build Coastguard Worker{ 662*58b9f456SAndroid Build Coastguard Worker} 663*58b9f456SAndroid Build Coastguard Worker 664*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> class _LIBCPP_TEMPLATE_VIS bitset; 665*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> struct hash<bitset<_Size> >; 666*58b9f456SAndroid Build Coastguard Worker 667*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 668*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS bitset 669*58b9f456SAndroid Build Coastguard Worker : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> 670*58b9f456SAndroid Build Coastguard Worker{ 671*58b9f456SAndroid Build Coastguard Workerpublic: 672*58b9f456SAndroid Build Coastguard Worker static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1; 673*58b9f456SAndroid Build Coastguard Worker typedef __bitset<__n_words, _Size> base; 674*58b9f456SAndroid Build Coastguard Worker 675*58b9f456SAndroid Build Coastguard Workerpublic: 676*58b9f456SAndroid Build Coastguard Worker typedef typename base::reference reference; 677*58b9f456SAndroid Build Coastguard Worker typedef typename base::const_reference const_reference; 678*58b9f456SAndroid Build Coastguard Worker 679*58b9f456SAndroid Build Coastguard Worker // 23.3.5.1 constructors: 680*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} 681*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 682*58b9f456SAndroid Build Coastguard Worker bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} 683*58b9f456SAndroid Build Coastguard Worker template<class _CharT> 684*58b9f456SAndroid Build Coastguard Worker explicit bitset(const _CharT* __str, 685*58b9f456SAndroid Build Coastguard Worker typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, 686*58b9f456SAndroid Build Coastguard Worker _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); 687*58b9f456SAndroid Build Coastguard Worker template<class _CharT, class _Traits, class _Allocator> 688*58b9f456SAndroid Build Coastguard Worker explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, 689*58b9f456SAndroid Build Coastguard Worker typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0, 690*58b9f456SAndroid Build Coastguard Worker typename basic_string<_CharT,_Traits,_Allocator>::size_type __n = 691*58b9f456SAndroid Build Coastguard Worker (basic_string<_CharT,_Traits,_Allocator>::npos), 692*58b9f456SAndroid Build Coastguard Worker _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); 693*58b9f456SAndroid Build Coastguard Worker 694*58b9f456SAndroid Build Coastguard Worker // 23.3.5.2 bitset operations: 695*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 696*58b9f456SAndroid Build Coastguard Worker bitset& operator&=(const bitset& __rhs) _NOEXCEPT; 697*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 698*58b9f456SAndroid Build Coastguard Worker bitset& operator|=(const bitset& __rhs) _NOEXCEPT; 699*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 700*58b9f456SAndroid Build Coastguard Worker bitset& operator^=(const bitset& __rhs) _NOEXCEPT; 701*58b9f456SAndroid Build Coastguard Worker bitset& operator<<=(size_t __pos) _NOEXCEPT; 702*58b9f456SAndroid Build Coastguard Worker bitset& operator>>=(size_t __pos) _NOEXCEPT; 703*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 704*58b9f456SAndroid Build Coastguard Worker bitset& set() _NOEXCEPT; 705*58b9f456SAndroid Build Coastguard Worker bitset& set(size_t __pos, bool __val = true); 706*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 707*58b9f456SAndroid Build Coastguard Worker bitset& reset() _NOEXCEPT; 708*58b9f456SAndroid Build Coastguard Worker bitset& reset(size_t __pos); 709*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 710*58b9f456SAndroid Build Coastguard Worker bitset operator~() const _NOEXCEPT; 711*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 712*58b9f456SAndroid Build Coastguard Worker bitset& flip() _NOEXCEPT; 713*58b9f456SAndroid Build Coastguard Worker bitset& flip(size_t __pos); 714*58b9f456SAndroid Build Coastguard Worker 715*58b9f456SAndroid Build Coastguard Worker // element access: 716*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 717*58b9f456SAndroid Build Coastguard Worker const_reference operator[](size_t __p) const {return base::__make_ref(__p);} 718*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);} 719*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 720*58b9f456SAndroid Build Coastguard Worker unsigned long to_ulong() const; 721*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 722*58b9f456SAndroid Build Coastguard Worker unsigned long long to_ullong() const; 723*58b9f456SAndroid Build Coastguard Worker template <class _CharT, class _Traits, class _Allocator> 724*58b9f456SAndroid Build Coastguard Worker basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'), 725*58b9f456SAndroid Build Coastguard Worker _CharT __one = _CharT('1')) const; 726*58b9f456SAndroid Build Coastguard Worker template <class _CharT, class _Traits> 727*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 728*58b9f456SAndroid Build Coastguard Worker basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), 729*58b9f456SAndroid Build Coastguard Worker _CharT __one = _CharT('1')) const; 730*58b9f456SAndroid Build Coastguard Worker template <class _CharT> 731*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 732*58b9f456SAndroid Build Coastguard Worker basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), 733*58b9f456SAndroid Build Coastguard Worker _CharT __one = _CharT('1')) const; 734*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 735*58b9f456SAndroid Build Coastguard Worker basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0', 736*58b9f456SAndroid Build Coastguard Worker char __one = '1') const; 737*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 738*58b9f456SAndroid Build Coastguard Worker size_t count() const _NOEXCEPT; 739*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;} 740*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 741*58b9f456SAndroid Build Coastguard Worker bool operator==(const bitset& __rhs) const _NOEXCEPT; 742*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 743*58b9f456SAndroid Build Coastguard Worker bool operator!=(const bitset& __rhs) const _NOEXCEPT; 744*58b9f456SAndroid Build Coastguard Worker bool test(size_t __pos) const; 745*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 746*58b9f456SAndroid Build Coastguard Worker bool all() const _NOEXCEPT; 747*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 748*58b9f456SAndroid Build Coastguard Worker bool any() const _NOEXCEPT; 749*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();} 750*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 751*58b9f456SAndroid Build Coastguard Worker bitset operator<<(size_t __pos) const _NOEXCEPT; 752*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 753*58b9f456SAndroid Build Coastguard Worker bitset operator>>(size_t __pos) const _NOEXCEPT; 754*58b9f456SAndroid Build Coastguard Worker 755*58b9f456SAndroid Build Coastguard Workerprivate: 756*58b9f456SAndroid Build Coastguard Worker 757*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 758*58b9f456SAndroid Build Coastguard Worker size_t __hash_code() const _NOEXCEPT {return base::__hash_code();} 759*58b9f456SAndroid Build Coastguard Worker 760*58b9f456SAndroid Build Coastguard Worker friend struct hash<bitset>; 761*58b9f456SAndroid Build Coastguard Worker}; 762*58b9f456SAndroid Build Coastguard Worker 763*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 764*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT> 765*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::bitset(const _CharT* __str, 766*58b9f456SAndroid Build Coastguard Worker typename basic_string<_CharT>::size_type __n, 767*58b9f456SAndroid Build Coastguard Worker _CharT __zero, _CharT __one) 768*58b9f456SAndroid Build Coastguard Worker{ 769*58b9f456SAndroid Build Coastguard Worker size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str)); 770*58b9f456SAndroid Build Coastguard Worker for (size_t __i = 0; __i < __rlen; ++__i) 771*58b9f456SAndroid Build Coastguard Worker if (__str[__i] != __zero && __str[__i] != __one) 772*58b9f456SAndroid Build Coastguard Worker __throw_invalid_argument("bitset string ctor has invalid argument"); 773*58b9f456SAndroid Build Coastguard Worker 774*58b9f456SAndroid Build Coastguard Worker size_t _Mp = _VSTD::min(__rlen, _Size); 775*58b9f456SAndroid Build Coastguard Worker size_t __i = 0; 776*58b9f456SAndroid Build Coastguard Worker for (; __i < _Mp; ++__i) 777*58b9f456SAndroid Build Coastguard Worker { 778*58b9f456SAndroid Build Coastguard Worker _CharT __c = __str[_Mp - 1 - __i]; 779*58b9f456SAndroid Build Coastguard Worker if (__c == __zero) 780*58b9f456SAndroid Build Coastguard Worker (*this)[__i] = false; 781*58b9f456SAndroid Build Coastguard Worker else 782*58b9f456SAndroid Build Coastguard Worker (*this)[__i] = true; 783*58b9f456SAndroid Build Coastguard Worker } 784*58b9f456SAndroid Build Coastguard Worker _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false); 785*58b9f456SAndroid Build Coastguard Worker} 786*58b9f456SAndroid Build Coastguard Worker 787*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 788*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits, class _Allocator> 789*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, 790*58b9f456SAndroid Build Coastguard Worker typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos, 791*58b9f456SAndroid Build Coastguard Worker typename basic_string<_CharT,_Traits,_Allocator>::size_type __n, 792*58b9f456SAndroid Build Coastguard Worker _CharT __zero, _CharT __one) 793*58b9f456SAndroid Build Coastguard Worker{ 794*58b9f456SAndroid Build Coastguard Worker if (__pos > __str.size()) 795*58b9f456SAndroid Build Coastguard Worker __throw_out_of_range("bitset string pos out of range"); 796*58b9f456SAndroid Build Coastguard Worker 797*58b9f456SAndroid Build Coastguard Worker size_t __rlen = _VSTD::min(__n, __str.size() - __pos); 798*58b9f456SAndroid Build Coastguard Worker for (size_t __i = __pos; __i < __pos + __rlen; ++__i) 799*58b9f456SAndroid Build Coastguard Worker if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one)) 800*58b9f456SAndroid Build Coastguard Worker __throw_invalid_argument("bitset string ctor has invalid argument"); 801*58b9f456SAndroid Build Coastguard Worker 802*58b9f456SAndroid Build Coastguard Worker size_t _Mp = _VSTD::min(__rlen, _Size); 803*58b9f456SAndroid Build Coastguard Worker size_t __i = 0; 804*58b9f456SAndroid Build Coastguard Worker for (; __i < _Mp; ++__i) 805*58b9f456SAndroid Build Coastguard Worker { 806*58b9f456SAndroid Build Coastguard Worker _CharT __c = __str[__pos + _Mp - 1 - __i]; 807*58b9f456SAndroid Build Coastguard Worker if (_Traits::eq(__c, __zero)) 808*58b9f456SAndroid Build Coastguard Worker (*this)[__i] = false; 809*58b9f456SAndroid Build Coastguard Worker else 810*58b9f456SAndroid Build Coastguard Worker (*this)[__i] = true; 811*58b9f456SAndroid Build Coastguard Worker } 812*58b9f456SAndroid Build Coastguard Worker _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false); 813*58b9f456SAndroid Build Coastguard Worker} 814*58b9f456SAndroid Build Coastguard Worker 815*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 816*58b9f456SAndroid Build Coastguard Workerinline 817*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 818*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT 819*58b9f456SAndroid Build Coastguard Worker{ 820*58b9f456SAndroid Build Coastguard Worker base::operator&=(__rhs); 821*58b9f456SAndroid Build Coastguard Worker return *this; 822*58b9f456SAndroid Build Coastguard Worker} 823*58b9f456SAndroid Build Coastguard Worker 824*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 825*58b9f456SAndroid Build Coastguard Workerinline 826*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 827*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT 828*58b9f456SAndroid Build Coastguard Worker{ 829*58b9f456SAndroid Build Coastguard Worker base::operator|=(__rhs); 830*58b9f456SAndroid Build Coastguard Worker return *this; 831*58b9f456SAndroid Build Coastguard Worker} 832*58b9f456SAndroid Build Coastguard Worker 833*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 834*58b9f456SAndroid Build Coastguard Workerinline 835*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 836*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT 837*58b9f456SAndroid Build Coastguard Worker{ 838*58b9f456SAndroid Build Coastguard Worker base::operator^=(__rhs); 839*58b9f456SAndroid Build Coastguard Worker return *this; 840*58b9f456SAndroid Build Coastguard Worker} 841*58b9f456SAndroid Build Coastguard Worker 842*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 843*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 844*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT 845*58b9f456SAndroid Build Coastguard Worker{ 846*58b9f456SAndroid Build Coastguard Worker __pos = _VSTD::min(__pos, _Size); 847*58b9f456SAndroid Build Coastguard Worker _VSTD::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size)); 848*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(base::__make_iter(0), __pos, false); 849*58b9f456SAndroid Build Coastguard Worker return *this; 850*58b9f456SAndroid Build Coastguard Worker} 851*58b9f456SAndroid Build Coastguard Worker 852*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 853*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 854*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT 855*58b9f456SAndroid Build Coastguard Worker{ 856*58b9f456SAndroid Build Coastguard Worker __pos = _VSTD::min(__pos, _Size); 857*58b9f456SAndroid Build Coastguard Worker _VSTD::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0)); 858*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(base::__make_iter(_Size - __pos), __pos, false); 859*58b9f456SAndroid Build Coastguard Worker return *this; 860*58b9f456SAndroid Build Coastguard Worker} 861*58b9f456SAndroid Build Coastguard Worker 862*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 863*58b9f456SAndroid Build Coastguard Workerinline 864*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 865*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::set() _NOEXCEPT 866*58b9f456SAndroid Build Coastguard Worker{ 867*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(base::__make_iter(0), _Size, true); 868*58b9f456SAndroid Build Coastguard Worker return *this; 869*58b9f456SAndroid Build Coastguard Worker} 870*58b9f456SAndroid Build Coastguard Worker 871*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 872*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 873*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::set(size_t __pos, bool __val) 874*58b9f456SAndroid Build Coastguard Worker{ 875*58b9f456SAndroid Build Coastguard Worker if (__pos >= _Size) 876*58b9f456SAndroid Build Coastguard Worker __throw_out_of_range("bitset set argument out of range"); 877*58b9f456SAndroid Build Coastguard Worker 878*58b9f456SAndroid Build Coastguard Worker (*this)[__pos] = __val; 879*58b9f456SAndroid Build Coastguard Worker return *this; 880*58b9f456SAndroid Build Coastguard Worker} 881*58b9f456SAndroid Build Coastguard Worker 882*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 883*58b9f456SAndroid Build Coastguard Workerinline 884*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 885*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::reset() _NOEXCEPT 886*58b9f456SAndroid Build Coastguard Worker{ 887*58b9f456SAndroid Build Coastguard Worker _VSTD::fill_n(base::__make_iter(0), _Size, false); 888*58b9f456SAndroid Build Coastguard Worker return *this; 889*58b9f456SAndroid Build Coastguard Worker} 890*58b9f456SAndroid Build Coastguard Worker 891*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 892*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 893*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::reset(size_t __pos) 894*58b9f456SAndroid Build Coastguard Worker{ 895*58b9f456SAndroid Build Coastguard Worker if (__pos >= _Size) 896*58b9f456SAndroid Build Coastguard Worker __throw_out_of_range("bitset reset argument out of range"); 897*58b9f456SAndroid Build Coastguard Worker 898*58b9f456SAndroid Build Coastguard Worker (*this)[__pos] = false; 899*58b9f456SAndroid Build Coastguard Worker return *this; 900*58b9f456SAndroid Build Coastguard Worker} 901*58b9f456SAndroid Build Coastguard Worker 902*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 903*58b9f456SAndroid Build Coastguard Workerinline 904*58b9f456SAndroid Build Coastguard Workerbitset<_Size> 905*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator~() const _NOEXCEPT 906*58b9f456SAndroid Build Coastguard Worker{ 907*58b9f456SAndroid Build Coastguard Worker bitset __x(*this); 908*58b9f456SAndroid Build Coastguard Worker __x.flip(); 909*58b9f456SAndroid Build Coastguard Worker return __x; 910*58b9f456SAndroid Build Coastguard Worker} 911*58b9f456SAndroid Build Coastguard Worker 912*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 913*58b9f456SAndroid Build Coastguard Workerinline 914*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 915*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::flip() _NOEXCEPT 916*58b9f456SAndroid Build Coastguard Worker{ 917*58b9f456SAndroid Build Coastguard Worker base::flip(); 918*58b9f456SAndroid Build Coastguard Worker return *this; 919*58b9f456SAndroid Build Coastguard Worker} 920*58b9f456SAndroid Build Coastguard Worker 921*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 922*58b9f456SAndroid Build Coastguard Workerbitset<_Size>& 923*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::flip(size_t __pos) 924*58b9f456SAndroid Build Coastguard Worker{ 925*58b9f456SAndroid Build Coastguard Worker if (__pos >= _Size) 926*58b9f456SAndroid Build Coastguard Worker __throw_out_of_range("bitset flip argument out of range"); 927*58b9f456SAndroid Build Coastguard Worker 928*58b9f456SAndroid Build Coastguard Worker reference r = base::__make_ref(__pos); 929*58b9f456SAndroid Build Coastguard Worker r = ~r; 930*58b9f456SAndroid Build Coastguard Worker return *this; 931*58b9f456SAndroid Build Coastguard Worker} 932*58b9f456SAndroid Build Coastguard Worker 933*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 934*58b9f456SAndroid Build Coastguard Workerinline 935*58b9f456SAndroid Build Coastguard Workerunsigned long 936*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::to_ulong() const 937*58b9f456SAndroid Build Coastguard Worker{ 938*58b9f456SAndroid Build Coastguard Worker return base::to_ulong(); 939*58b9f456SAndroid Build Coastguard Worker} 940*58b9f456SAndroid Build Coastguard Worker 941*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 942*58b9f456SAndroid Build Coastguard Workerinline 943*58b9f456SAndroid Build Coastguard Workerunsigned long long 944*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::to_ullong() const 945*58b9f456SAndroid Build Coastguard Worker{ 946*58b9f456SAndroid Build Coastguard Worker return base::to_ullong(); 947*58b9f456SAndroid Build Coastguard Worker} 948*58b9f456SAndroid Build Coastguard Worker 949*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 950*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator> 951*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, _Allocator> 952*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 953*58b9f456SAndroid Build Coastguard Worker{ 954*58b9f456SAndroid Build Coastguard Worker basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero); 955*58b9f456SAndroid Build Coastguard Worker for (size_t __i = 0; __i < _Size; ++__i) 956*58b9f456SAndroid Build Coastguard Worker { 957*58b9f456SAndroid Build Coastguard Worker if ((*this)[__i]) 958*58b9f456SAndroid Build Coastguard Worker __r[_Size - 1 - __i] = __one; 959*58b9f456SAndroid Build Coastguard Worker } 960*58b9f456SAndroid Build Coastguard Worker return __r; 961*58b9f456SAndroid Build Coastguard Worker} 962*58b9f456SAndroid Build Coastguard Worker 963*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 964*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits> 965*58b9f456SAndroid Build Coastguard Workerinline 966*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, _Traits, allocator<_CharT> > 967*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 968*58b9f456SAndroid Build Coastguard Worker{ 969*58b9f456SAndroid Build Coastguard Worker return to_string<_CharT, _Traits, allocator<_CharT> >(__zero, __one); 970*58b9f456SAndroid Build Coastguard Worker} 971*58b9f456SAndroid Build Coastguard Worker 972*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 973*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT> 974*58b9f456SAndroid Build Coastguard Workerinline 975*58b9f456SAndroid Build Coastguard Workerbasic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > 976*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 977*58b9f456SAndroid Build Coastguard Worker{ 978*58b9f456SAndroid Build Coastguard Worker return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(__zero, __one); 979*58b9f456SAndroid Build Coastguard Worker} 980*58b9f456SAndroid Build Coastguard Worker 981*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 982*58b9f456SAndroid Build Coastguard Workerinline 983*58b9f456SAndroid Build Coastguard Workerbasic_string<char, char_traits<char>, allocator<char> > 984*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::to_string(char __zero, char __one) const 985*58b9f456SAndroid Build Coastguard Worker{ 986*58b9f456SAndroid Build Coastguard Worker return to_string<char, char_traits<char>, allocator<char> >(__zero, __one); 987*58b9f456SAndroid Build Coastguard Worker} 988*58b9f456SAndroid Build Coastguard Worker 989*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 990*58b9f456SAndroid Build Coastguard Workerinline 991*58b9f456SAndroid Build Coastguard Workersize_t 992*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::count() const _NOEXCEPT 993*58b9f456SAndroid Build Coastguard Worker{ 994*58b9f456SAndroid Build Coastguard Worker return static_cast<size_t>(__count_bool_true(base::__make_iter(0), _Size)); 995*58b9f456SAndroid Build Coastguard Worker} 996*58b9f456SAndroid Build Coastguard Worker 997*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 998*58b9f456SAndroid Build Coastguard Workerinline 999*58b9f456SAndroid Build Coastguard Workerbool 1000*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT 1001*58b9f456SAndroid Build Coastguard Worker{ 1002*58b9f456SAndroid Build Coastguard Worker return _VSTD::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0)); 1003*58b9f456SAndroid Build Coastguard Worker} 1004*58b9f456SAndroid Build Coastguard Worker 1005*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1006*58b9f456SAndroid Build Coastguard Workerinline 1007*58b9f456SAndroid Build Coastguard Workerbool 1008*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT 1009*58b9f456SAndroid Build Coastguard Worker{ 1010*58b9f456SAndroid Build Coastguard Worker return !(*this == __rhs); 1011*58b9f456SAndroid Build Coastguard Worker} 1012*58b9f456SAndroid Build Coastguard Worker 1013*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1014*58b9f456SAndroid Build Coastguard Workerbool 1015*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::test(size_t __pos) const 1016*58b9f456SAndroid Build Coastguard Worker{ 1017*58b9f456SAndroid Build Coastguard Worker if (__pos >= _Size) 1018*58b9f456SAndroid Build Coastguard Worker __throw_out_of_range("bitset test argument out of range"); 1019*58b9f456SAndroid Build Coastguard Worker 1020*58b9f456SAndroid Build Coastguard Worker return (*this)[__pos]; 1021*58b9f456SAndroid Build Coastguard Worker} 1022*58b9f456SAndroid Build Coastguard Worker 1023*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1024*58b9f456SAndroid Build Coastguard Workerinline 1025*58b9f456SAndroid Build Coastguard Workerbool 1026*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::all() const _NOEXCEPT 1027*58b9f456SAndroid Build Coastguard Worker{ 1028*58b9f456SAndroid Build Coastguard Worker return base::all(); 1029*58b9f456SAndroid Build Coastguard Worker} 1030*58b9f456SAndroid Build Coastguard Worker 1031*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1032*58b9f456SAndroid Build Coastguard Workerinline 1033*58b9f456SAndroid Build Coastguard Workerbool 1034*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::any() const _NOEXCEPT 1035*58b9f456SAndroid Build Coastguard Worker{ 1036*58b9f456SAndroid Build Coastguard Worker return base::any(); 1037*58b9f456SAndroid Build Coastguard Worker} 1038*58b9f456SAndroid Build Coastguard Worker 1039*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1040*58b9f456SAndroid Build Coastguard Workerinline 1041*58b9f456SAndroid Build Coastguard Workerbitset<_Size> 1042*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT 1043*58b9f456SAndroid Build Coastguard Worker{ 1044*58b9f456SAndroid Build Coastguard Worker bitset __r = *this; 1045*58b9f456SAndroid Build Coastguard Worker __r <<= __pos; 1046*58b9f456SAndroid Build Coastguard Worker return __r; 1047*58b9f456SAndroid Build Coastguard Worker} 1048*58b9f456SAndroid Build Coastguard Worker 1049*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1050*58b9f456SAndroid Build Coastguard Workerinline 1051*58b9f456SAndroid Build Coastguard Workerbitset<_Size> 1052*58b9f456SAndroid Build Coastguard Workerbitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT 1053*58b9f456SAndroid Build Coastguard Worker{ 1054*58b9f456SAndroid Build Coastguard Worker bitset __r = *this; 1055*58b9f456SAndroid Build Coastguard Worker __r >>= __pos; 1056*58b9f456SAndroid Build Coastguard Worker return __r; 1057*58b9f456SAndroid Build Coastguard Worker} 1058*58b9f456SAndroid Build Coastguard Worker 1059*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1060*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1061*58b9f456SAndroid Build Coastguard Workerbitset<_Size> 1062*58b9f456SAndroid Build Coastguard Workeroperator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 1063*58b9f456SAndroid Build Coastguard Worker{ 1064*58b9f456SAndroid Build Coastguard Worker bitset<_Size> __r = __x; 1065*58b9f456SAndroid Build Coastguard Worker __r &= __y; 1066*58b9f456SAndroid Build Coastguard Worker return __r; 1067*58b9f456SAndroid Build Coastguard Worker} 1068*58b9f456SAndroid Build Coastguard Worker 1069*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1070*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1071*58b9f456SAndroid Build Coastguard Workerbitset<_Size> 1072*58b9f456SAndroid Build Coastguard Workeroperator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 1073*58b9f456SAndroid Build Coastguard Worker{ 1074*58b9f456SAndroid Build Coastguard Worker bitset<_Size> __r = __x; 1075*58b9f456SAndroid Build Coastguard Worker __r |= __y; 1076*58b9f456SAndroid Build Coastguard Worker return __r; 1077*58b9f456SAndroid Build Coastguard Worker} 1078*58b9f456SAndroid Build Coastguard Worker 1079*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1080*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 1081*58b9f456SAndroid Build Coastguard Workerbitset<_Size> 1082*58b9f456SAndroid Build Coastguard Workeroperator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 1083*58b9f456SAndroid Build Coastguard Worker{ 1084*58b9f456SAndroid Build Coastguard Worker bitset<_Size> __r = __x; 1085*58b9f456SAndroid Build Coastguard Worker __r ^= __y; 1086*58b9f456SAndroid Build Coastguard Worker return __r; 1087*58b9f456SAndroid Build Coastguard Worker} 1088*58b9f456SAndroid Build Coastguard Worker 1089*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size> 1090*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> > 1091*58b9f456SAndroid Build Coastguard Worker : public unary_function<bitset<_Size>, size_t> 1092*58b9f456SAndroid Build Coastguard Worker{ 1093*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 1094*58b9f456SAndroid Build Coastguard Worker size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT 1095*58b9f456SAndroid Build Coastguard Worker {return __bs.__hash_code();} 1096*58b9f456SAndroid Build Coastguard Worker}; 1097*58b9f456SAndroid Build Coastguard Worker 1098*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, size_t _Size> 1099*58b9f456SAndroid Build Coastguard Workerbasic_istream<_CharT, _Traits>& 1100*58b9f456SAndroid Build Coastguard Workeroperator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x); 1101*58b9f456SAndroid Build Coastguard Worker 1102*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, size_t _Size> 1103*58b9f456SAndroid Build Coastguard Workerbasic_ostream<_CharT, _Traits>& 1104*58b9f456SAndroid Build Coastguard Workeroperator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x); 1105*58b9f456SAndroid Build Coastguard Worker 1106*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD 1107*58b9f456SAndroid Build Coastguard Worker 1108*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS 1109*58b9f456SAndroid Build Coastguard Worker 1110*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_BITSET 1111