14684ddb6SLionel Sambuc// -*- C++ -*- 24684ddb6SLionel Sambuc//===---------------------------- bitset ----------------------------------===// 34684ddb6SLionel Sambuc// 44684ddb6SLionel Sambuc// The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc// 64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open 74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc// 94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuc#ifndef _LIBCPP_BITSET 124684ddb6SLionel Sambuc#define _LIBCPP_BITSET 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc/* 154684ddb6SLionel Sambuc bitset synopsis 164684ddb6SLionel Sambuc 174684ddb6SLionel Sambucnamespace std 184684ddb6SLionel Sambuc{ 194684ddb6SLionel Sambuc 204684ddb6SLionel Sambucnamespace std { 214684ddb6SLionel Sambuc 224684ddb6SLionel Sambuctemplate <size_t N> 234684ddb6SLionel Sambucclass bitset 244684ddb6SLionel Sambuc{ 254684ddb6SLionel Sambucpublic: 264684ddb6SLionel Sambuc // bit reference: 274684ddb6SLionel Sambuc class reference 284684ddb6SLionel Sambuc { 294684ddb6SLionel Sambuc friend class bitset; 304684ddb6SLionel Sambuc reference() noexcept; 314684ddb6SLionel Sambuc public: 324684ddb6SLionel Sambuc ~reference() noexcept; 334684ddb6SLionel Sambuc reference& operator=(bool x) noexcept; // for b[i] = x; 344684ddb6SLionel Sambuc reference& operator=(const reference&) noexcept; // for b[i] = b[j]; 354684ddb6SLionel Sambuc bool operator~() const noexcept; // flips the bit 364684ddb6SLionel Sambuc operator bool() const noexcept; // for x = b[i]; 374684ddb6SLionel Sambuc reference& flip() noexcept; // for b[i].flip(); 384684ddb6SLionel Sambuc }; 394684ddb6SLionel Sambuc 404684ddb6SLionel Sambuc // 23.3.5.1 constructors: 414684ddb6SLionel Sambuc constexpr bitset() noexcept; 424684ddb6SLionel Sambuc constexpr bitset(unsigned long long val) noexcept; 434684ddb6SLionel Sambuc template <class charT> 444684ddb6SLionel Sambuc explicit bitset(const charT* str, 454684ddb6SLionel Sambuc typename basic_string<charT>::size_type n = basic_string<charT>::npos, 464684ddb6SLionel Sambuc charT zero = charT('0'), charT one = charT('1')); 474684ddb6SLionel Sambuc template<class charT, class traits, class Allocator> 484684ddb6SLionel Sambuc explicit bitset(const basic_string<charT,traits,Allocator>& str, 494684ddb6SLionel Sambuc typename basic_string<charT,traits,Allocator>::size_type pos = 0, 504684ddb6SLionel Sambuc typename basic_string<charT,traits,Allocator>::size_type n = 514684ddb6SLionel Sambuc basic_string<charT,traits,Allocator>::npos, 524684ddb6SLionel Sambuc charT zero = charT('0'), charT one = charT('1')); 534684ddb6SLionel Sambuc 544684ddb6SLionel Sambuc // 23.3.5.2 bitset operations: 554684ddb6SLionel Sambuc bitset& operator&=(const bitset& rhs) noexcept; 564684ddb6SLionel Sambuc bitset& operator|=(const bitset& rhs) noexcept; 574684ddb6SLionel Sambuc bitset& operator^=(const bitset& rhs) noexcept; 584684ddb6SLionel Sambuc bitset& operator<<=(size_t pos) noexcept; 594684ddb6SLionel Sambuc bitset& operator>>=(size_t pos) noexcept; 604684ddb6SLionel Sambuc bitset& set() noexcept; 614684ddb6SLionel Sambuc bitset& set(size_t pos, bool val = true); 624684ddb6SLionel Sambuc bitset& reset() noexcept; 634684ddb6SLionel Sambuc bitset& reset(size_t pos); 644684ddb6SLionel Sambuc bitset operator~() const noexcept; 654684ddb6SLionel Sambuc bitset& flip() noexcept; 664684ddb6SLionel Sambuc bitset& flip(size_t pos); 674684ddb6SLionel Sambuc 684684ddb6SLionel Sambuc // element access: 694684ddb6SLionel Sambuc constexpr bool operator[](size_t pos) const; // for b[i]; 704684ddb6SLionel Sambuc reference operator[](size_t pos); // for b[i]; 714684ddb6SLionel Sambuc unsigned long to_ulong() const; 724684ddb6SLionel Sambuc unsigned long long to_ullong() const; 734684ddb6SLionel Sambuc template <class charT, class traits, class Allocator> 744684ddb6SLionel Sambuc basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const; 754684ddb6SLionel Sambuc template <class charT, class traits> 764684ddb6SLionel Sambuc basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const; 774684ddb6SLionel Sambuc template <class charT> 784684ddb6SLionel Sambuc basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const; 794684ddb6SLionel Sambuc basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const; 804684ddb6SLionel Sambuc size_t count() const noexcept; 814684ddb6SLionel Sambuc constexpr size_t size() const noexcept; 824684ddb6SLionel Sambuc bool operator==(const bitset& rhs) const noexcept; 834684ddb6SLionel Sambuc bool operator!=(const bitset& rhs) const noexcept; 844684ddb6SLionel Sambuc bool test(size_t pos) const; 854684ddb6SLionel Sambuc bool all() const noexcept; 864684ddb6SLionel Sambuc bool any() const noexcept; 874684ddb6SLionel Sambuc bool none() const noexcept; 884684ddb6SLionel Sambuc bitset operator<<(size_t pos) const noexcept; 894684ddb6SLionel Sambuc bitset operator>>(size_t pos) const noexcept; 904684ddb6SLionel Sambuc}; 914684ddb6SLionel Sambuc 924684ddb6SLionel Sambuc// 23.3.5.3 bitset operators: 934684ddb6SLionel Sambuctemplate <size_t N> 944684ddb6SLionel Sambucbitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept; 954684ddb6SLionel Sambuc 964684ddb6SLionel Sambuctemplate <size_t N> 974684ddb6SLionel Sambucbitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept; 984684ddb6SLionel Sambuc 994684ddb6SLionel Sambuctemplate <size_t N> 1004684ddb6SLionel Sambucbitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept; 1014684ddb6SLionel Sambuc 1024684ddb6SLionel Sambuctemplate <class charT, class traits, size_t N> 1034684ddb6SLionel Sambucbasic_istream<charT, traits>& 1044684ddb6SLionel Sambucoperator>>(basic_istream<charT, traits>& is, bitset<N>& x); 1054684ddb6SLionel Sambuc 1064684ddb6SLionel Sambuctemplate <class charT, class traits, size_t N> 1074684ddb6SLionel Sambucbasic_ostream<charT, traits>& 1084684ddb6SLionel Sambucoperator<<(basic_ostream<charT, traits>& os, const bitset<N>& x); 1094684ddb6SLionel Sambuc 1104684ddb6SLionel Sambuctemplate <size_t N> struct hash<std::bitset<N>>; 1114684ddb6SLionel Sambuc 1124684ddb6SLionel Sambuc} // std 1134684ddb6SLionel Sambuc 1144684ddb6SLionel Sambuc*/ 1154684ddb6SLionel Sambuc 1164684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1174684ddb6SLionel Sambuc#pragma GCC system_header 1184684ddb6SLionel Sambuc#endif 1194684ddb6SLionel Sambuc 1204684ddb6SLionel Sambuc#include <__config> 1214684ddb6SLionel Sambuc#include <__bit_reference> 1224684ddb6SLionel Sambuc#include <cstddef> 1234684ddb6SLionel Sambuc#include <climits> 1244684ddb6SLionel Sambuc#include <string> 1254684ddb6SLionel Sambuc#include <stdexcept> 1264684ddb6SLionel Sambuc#include <iosfwd> 1274684ddb6SLionel Sambuc#include <__functional_base> 1284684ddb6SLionel Sambuc#if defined(_LIBCPP_NO_EXCEPTIONS) 1294684ddb6SLionel Sambuc #include <cassert> 1304684ddb6SLionel Sambuc#endif 1314684ddb6SLionel Sambuc 1324684ddb6SLionel Sambuc#include <__undef_min_max> 1334684ddb6SLionel Sambuc 1344684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD 1354684ddb6SLionel Sambuc 1364684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 1374684ddb6SLionel Sambucclass __bitset; 1384684ddb6SLionel Sambuc 1394684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 1404684ddb6SLionel Sambucstruct __has_storage_type<__bitset<_N_words, _Size> > 1414684ddb6SLionel Sambuc{ 1424684ddb6SLionel Sambuc static const bool value = true; 1434684ddb6SLionel Sambuc}; 1444684ddb6SLionel Sambuc 1454684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 1464684ddb6SLionel Sambucclass __bitset 1474684ddb6SLionel Sambuc{ 1484684ddb6SLionel Sambucpublic: 1494684ddb6SLionel Sambuc typedef ptrdiff_t difference_type; 1504684ddb6SLionel Sambuc typedef size_t size_type; 1514684ddb6SLionel Sambuc typedef size_type __storage_type; 1524684ddb6SLionel Sambucprotected: 1534684ddb6SLionel Sambuc typedef __bitset __self; 1544684ddb6SLionel Sambuc typedef __storage_type* __storage_pointer; 1554684ddb6SLionel Sambuc typedef const __storage_type* __const_storage_pointer; 1564684ddb6SLionel Sambuc static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 1574684ddb6SLionel Sambuc 1584684ddb6SLionel Sambuc friend class __bit_reference<__bitset>; 1594684ddb6SLionel Sambuc friend class __bit_const_reference<__bitset>; 1604684ddb6SLionel Sambuc friend class __bit_iterator<__bitset, false>; 1614684ddb6SLionel Sambuc friend class __bit_iterator<__bitset, true>; 1624684ddb6SLionel Sambuc friend struct __bit_array<__bitset>; 1634684ddb6SLionel Sambuc 1644684ddb6SLionel Sambuc __storage_type __first_[_N_words]; 1654684ddb6SLionel Sambuc 1664684ddb6SLionel Sambuc typedef __bit_reference<__bitset> reference; 1674684ddb6SLionel Sambuc typedef __bit_const_reference<__bitset> const_reference; 1684684ddb6SLionel Sambuc typedef __bit_iterator<__bitset, false> iterator; 1694684ddb6SLionel Sambuc typedef __bit_iterator<__bitset, true> const_iterator; 1704684ddb6SLionel Sambuc 1714684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 1724684ddb6SLionel Sambuc explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; 1734684ddb6SLionel Sambuc 1744684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT 1754684ddb6SLionel Sambuc {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} 1764684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT 1774684ddb6SLionel Sambuc {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} 1784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT 1794684ddb6SLionel Sambuc {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 1804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT 1814684ddb6SLionel Sambuc {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 1824684ddb6SLionel Sambuc 1834684ddb6SLionel Sambuc void operator&=(const __bitset& __v) _NOEXCEPT; 1844684ddb6SLionel Sambuc void operator|=(const __bitset& __v) _NOEXCEPT; 1854684ddb6SLionel Sambuc void operator^=(const __bitset& __v) _NOEXCEPT; 1864684ddb6SLionel Sambuc 1874684ddb6SLionel Sambuc void flip() _NOEXCEPT; 1884684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const 1894684ddb6SLionel Sambuc {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());} 1904684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const 1914684ddb6SLionel Sambuc {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());} 1924684ddb6SLionel Sambuc 1934684ddb6SLionel Sambuc bool all() const _NOEXCEPT; 1944684ddb6SLionel Sambuc bool any() const _NOEXCEPT; 1954684ddb6SLionel Sambuc size_t __hash_code() const _NOEXCEPT; 1964684ddb6SLionel Sambucprivate: 1974684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_CONSTEXPR 1984684ddb6SLionel Sambuc void __init(unsigned long long __v, false_type) _NOEXCEPT; 1994684ddb6SLionel Sambuc void __init(unsigned long long __v, true_type) _NOEXCEPT; 2004684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_CONSTEXPR 2014684ddb6SLionel Sambuc unsigned long to_ulong(false_type) const; 2024684ddb6SLionel Sambuc unsigned long to_ulong(true_type) const; 2034684ddb6SLionel Sambuc unsigned long long to_ullong(false_type) const; 2044684ddb6SLionel Sambuc unsigned long long to_ullong(true_type) const; 2054684ddb6SLionel Sambuc unsigned long long to_ullong(true_type, false_type) const; 2064684ddb6SLionel Sambuc unsigned long long to_ullong(true_type, true_type) const; 2074684ddb6SLionel Sambuc}; 2084684ddb6SLionel Sambuc 2094684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 2104684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2114684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 2124684ddb6SLionel Sambuc__bitset<_N_words, _Size>::__bitset() _NOEXCEPT 2134684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_CONSTEXPR 2144684ddb6SLionel Sambuc : __first_{0} 2154684ddb6SLionel Sambuc#endif 2164684ddb6SLionel Sambuc{ 2174684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_CONSTEXPR 2184684ddb6SLionel Sambuc _VSTD::fill_n(__first_, _N_words, __storage_type(0)); 2194684ddb6SLionel Sambuc#endif 2204684ddb6SLionel Sambuc} 2214684ddb6SLionel Sambuc 2224684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_CONSTEXPR 2234684ddb6SLionel Sambuc 2244684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 2254684ddb6SLionel Sambucvoid 2264684ddb6SLionel Sambuc__bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT 2274684ddb6SLionel Sambuc{ 2284684ddb6SLionel Sambuc __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)]; 2294684ddb6SLionel Sambuc for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word) 2304684ddb6SLionel Sambuc __t[__i] = static_cast<__storage_type>(__v); 2314684ddb6SLionel Sambuc _VSTD::copy(__t, __t + sizeof(__t)/sizeof(__t[0]), __first_); 2324684ddb6SLionel Sambuc _VSTD::fill(__first_ + sizeof(__t)/sizeof(__t[0]), __first_ + sizeof(__first_)/sizeof(__first_[0]), 2334684ddb6SLionel Sambuc __storage_type(0)); 2344684ddb6SLionel Sambuc} 2354684ddb6SLionel Sambuc 2364684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 2374684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2384684ddb6SLionel Sambucvoid 2394684ddb6SLionel Sambuc__bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT 2404684ddb6SLionel Sambuc{ 2414684ddb6SLionel Sambuc __first_[0] = __v; 2424684ddb6SLionel Sambuc _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0)); 2434684ddb6SLionel Sambuc} 2444684ddb6SLionel Sambuc 2454684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_CONSTEXPR 2464684ddb6SLionel Sambuc 2474684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 2484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2494684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 2504684ddb6SLionel Sambuc__bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT 2514684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_CONSTEXPR 252*0a6a1f1dSLionel Sambuc#if __SIZEOF_SIZE_T__ == 8 2534684ddb6SLionel Sambuc : __first_{__v} 254*0a6a1f1dSLionel Sambuc#elif __SIZEOF_SIZE_T__ == 4 2554684ddb6SLionel Sambuc : __first_{__v, __v >> __bits_per_word} 2564684ddb6SLionel Sambuc#else 2574684ddb6SLionel Sambuc#error This constructor has not been ported to this platform 2584684ddb6SLionel Sambuc#endif 2594684ddb6SLionel Sambuc#endif 2604684ddb6SLionel Sambuc{ 2614684ddb6SLionel Sambuc#ifdef _LIBCPP_HAS_NO_CONSTEXPR 2624684ddb6SLionel Sambuc __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>()); 2634684ddb6SLionel Sambuc#endif 2644684ddb6SLionel Sambuc} 2654684ddb6SLionel Sambuc 2664684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 2674684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2684684ddb6SLionel Sambucvoid 2694684ddb6SLionel Sambuc__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT 2704684ddb6SLionel Sambuc{ 2714684ddb6SLionel Sambuc for (size_type __i = 0; __i < _N_words; ++__i) 2724684ddb6SLionel Sambuc __first_[__i] &= __v.__first_[__i]; 2734684ddb6SLionel Sambuc} 2744684ddb6SLionel Sambuc 2754684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 2764684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2774684ddb6SLionel Sambucvoid 2784684ddb6SLionel Sambuc__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT 2794684ddb6SLionel Sambuc{ 2804684ddb6SLionel Sambuc for (size_type __i = 0; __i < _N_words; ++__i) 2814684ddb6SLionel Sambuc __first_[__i] |= __v.__first_[__i]; 2824684ddb6SLionel Sambuc} 2834684ddb6SLionel Sambuc 2844684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 2854684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2864684ddb6SLionel Sambucvoid 2874684ddb6SLionel Sambuc__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT 2884684ddb6SLionel Sambuc{ 2894684ddb6SLionel Sambuc for (size_type __i = 0; __i < _N_words; ++__i) 2904684ddb6SLionel Sambuc __first_[__i] ^= __v.__first_[__i]; 2914684ddb6SLionel Sambuc} 2924684ddb6SLionel Sambuc 2934684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 2944684ddb6SLionel Sambucvoid 2954684ddb6SLionel Sambuc__bitset<_N_words, _Size>::flip() _NOEXCEPT 2964684ddb6SLionel Sambuc{ 2974684ddb6SLionel Sambuc // do middle whole words 2984684ddb6SLionel Sambuc size_type __n = _Size; 2994684ddb6SLionel Sambuc __storage_pointer __p = __first_; 3004684ddb6SLionel Sambuc for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 3014684ddb6SLionel Sambuc *__p = ~*__p; 3024684ddb6SLionel Sambuc // do last partial word 3034684ddb6SLionel Sambuc if (__n > 0) 3044684ddb6SLionel Sambuc { 3054684ddb6SLionel Sambuc __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 3064684ddb6SLionel Sambuc __storage_type __b = *__p & __m; 3074684ddb6SLionel Sambuc *__p &= ~__m; 3084684ddb6SLionel Sambuc *__p |= ~__b & __m; 3094684ddb6SLionel Sambuc } 3104684ddb6SLionel Sambuc} 3114684ddb6SLionel Sambuc 3124684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 3134684ddb6SLionel Sambucunsigned long 3144684ddb6SLionel Sambuc__bitset<_N_words, _Size>::to_ulong(false_type) const 3154684ddb6SLionel Sambuc{ 3164684ddb6SLionel Sambuc const_iterator __e = __make_iter(_Size); 3174684ddb6SLionel Sambuc const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true); 3184684ddb6SLionel Sambuc if (__i != __e) 3194684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3204684ddb6SLionel Sambuc throw overflow_error("bitset to_ulong overflow error"); 3214684ddb6SLionel Sambuc#else 3224684ddb6SLionel Sambuc assert(!"bitset to_ulong overflow error"); 3234684ddb6SLionel Sambuc#endif 3244684ddb6SLionel Sambuc return __first_[0]; 3254684ddb6SLionel Sambuc} 3264684ddb6SLionel Sambuc 3274684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 3284684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3294684ddb6SLionel Sambucunsigned long 3304684ddb6SLionel Sambuc__bitset<_N_words, _Size>::to_ulong(true_type) const 3314684ddb6SLionel Sambuc{ 3324684ddb6SLionel Sambuc return __first_[0]; 3334684ddb6SLionel Sambuc} 3344684ddb6SLionel Sambuc 3354684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 3364684ddb6SLionel Sambucunsigned long long 3374684ddb6SLionel Sambuc__bitset<_N_words, _Size>::to_ullong(false_type) const 3384684ddb6SLionel Sambuc{ 3394684ddb6SLionel Sambuc const_iterator __e = __make_iter(_Size); 3404684ddb6SLionel Sambuc const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true); 3414684ddb6SLionel Sambuc if (__i != __e) 3424684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 3434684ddb6SLionel Sambuc throw overflow_error("bitset to_ullong overflow error"); 3444684ddb6SLionel Sambuc#else 3454684ddb6SLionel Sambuc assert(!"bitset to_ullong overflow error"); 3464684ddb6SLionel Sambuc#endif 3474684ddb6SLionel Sambuc return to_ullong(true_type()); 3484684ddb6SLionel Sambuc} 3494684ddb6SLionel Sambuc 3504684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 3514684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3524684ddb6SLionel Sambucunsigned long long 3534684ddb6SLionel Sambuc__bitset<_N_words, _Size>::to_ullong(true_type) const 3544684ddb6SLionel Sambuc{ 3554684ddb6SLionel Sambuc return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>()); 3564684ddb6SLionel Sambuc} 3574684ddb6SLionel Sambuc 3584684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 3594684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 3604684ddb6SLionel Sambucunsigned long long 3614684ddb6SLionel Sambuc__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const 3624684ddb6SLionel Sambuc{ 3634684ddb6SLionel Sambuc return __first_[0]; 3644684ddb6SLionel Sambuc} 3654684ddb6SLionel Sambuc 3664684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 3674684ddb6SLionel Sambucunsigned long long 3684684ddb6SLionel Sambuc__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const 3694684ddb6SLionel Sambuc{ 3704684ddb6SLionel Sambuc unsigned long long __r = __first_[0]; 3714684ddb6SLionel Sambuc for (std::size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i) 3724684ddb6SLionel Sambuc __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT); 3734684ddb6SLionel Sambuc return __r; 3744684ddb6SLionel Sambuc} 3754684ddb6SLionel Sambuc 3764684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 3774684ddb6SLionel Sambucbool 3784684ddb6SLionel Sambuc__bitset<_N_words, _Size>::all() const _NOEXCEPT 3794684ddb6SLionel Sambuc{ 3804684ddb6SLionel Sambuc // do middle whole words 3814684ddb6SLionel Sambuc size_type __n = _Size; 3824684ddb6SLionel Sambuc __const_storage_pointer __p = __first_; 3834684ddb6SLionel Sambuc for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 3844684ddb6SLionel Sambuc if (~*__p) 3854684ddb6SLionel Sambuc return false; 3864684ddb6SLionel Sambuc // do last partial word 3874684ddb6SLionel Sambuc if (__n > 0) 3884684ddb6SLionel Sambuc { 3894684ddb6SLionel Sambuc __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 3904684ddb6SLionel Sambuc if (~*__p & __m) 3914684ddb6SLionel Sambuc return false; 3924684ddb6SLionel Sambuc } 3934684ddb6SLionel Sambuc return true; 3944684ddb6SLionel Sambuc} 3954684ddb6SLionel Sambuc 3964684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 3974684ddb6SLionel Sambucbool 3984684ddb6SLionel Sambuc__bitset<_N_words, _Size>::any() const _NOEXCEPT 3994684ddb6SLionel Sambuc{ 4004684ddb6SLionel Sambuc // do middle whole words 4014684ddb6SLionel Sambuc size_type __n = _Size; 4024684ddb6SLionel Sambuc __const_storage_pointer __p = __first_; 4034684ddb6SLionel Sambuc for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) 4044684ddb6SLionel Sambuc if (*__p) 4054684ddb6SLionel Sambuc return true; 4064684ddb6SLionel Sambuc // do last partial word 4074684ddb6SLionel Sambuc if (__n > 0) 4084684ddb6SLionel Sambuc { 4094684ddb6SLionel Sambuc __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); 4104684ddb6SLionel Sambuc if (*__p & __m) 4114684ddb6SLionel Sambuc return true; 4124684ddb6SLionel Sambuc } 4134684ddb6SLionel Sambuc return false; 4144684ddb6SLionel Sambuc} 4154684ddb6SLionel Sambuc 4164684ddb6SLionel Sambuctemplate <size_t _N_words, size_t _Size> 4174684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4184684ddb6SLionel Sambucsize_t 4194684ddb6SLionel Sambuc__bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT 4204684ddb6SLionel Sambuc{ 4214684ddb6SLionel Sambuc size_t __h = 0; 4224684ddb6SLionel Sambuc for (size_type __i = 0; __i < _N_words; ++__i) 4234684ddb6SLionel Sambuc __h ^= __first_[__i]; 4244684ddb6SLionel Sambuc return __h; 4254684ddb6SLionel Sambuc} 4264684ddb6SLionel Sambuc 4274684ddb6SLionel Sambuctemplate <size_t _Size> 4284684ddb6SLionel Sambucclass __bitset<1, _Size> 4294684ddb6SLionel Sambuc{ 4304684ddb6SLionel Sambucpublic: 4314684ddb6SLionel Sambuc typedef ptrdiff_t difference_type; 4324684ddb6SLionel Sambuc typedef size_t size_type; 4334684ddb6SLionel Sambuc typedef size_type __storage_type; 4344684ddb6SLionel Sambucprotected: 4354684ddb6SLionel Sambuc typedef __bitset __self; 4364684ddb6SLionel Sambuc typedef __storage_type* __storage_pointer; 4374684ddb6SLionel Sambuc typedef const __storage_type* __const_storage_pointer; 4384684ddb6SLionel Sambuc static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 4394684ddb6SLionel Sambuc 4404684ddb6SLionel Sambuc friend class __bit_reference<__bitset>; 4414684ddb6SLionel Sambuc friend class __bit_const_reference<__bitset>; 4424684ddb6SLionel Sambuc friend class __bit_iterator<__bitset, false>; 4434684ddb6SLionel Sambuc friend class __bit_iterator<__bitset, true>; 4444684ddb6SLionel Sambuc friend struct __bit_array<__bitset>; 4454684ddb6SLionel Sambuc 4464684ddb6SLionel Sambuc __storage_type __first_; 4474684ddb6SLionel Sambuc 4484684ddb6SLionel Sambuc typedef __bit_reference<__bitset> reference; 4494684ddb6SLionel Sambuc typedef __bit_const_reference<__bitset> const_reference; 4504684ddb6SLionel Sambuc typedef __bit_iterator<__bitset, false> iterator; 4514684ddb6SLionel Sambuc typedef __bit_iterator<__bitset, true> const_iterator; 4524684ddb6SLionel Sambuc 4534684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 4544684ddb6SLionel Sambuc explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; 4554684ddb6SLionel Sambuc 4564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT 4574684ddb6SLionel Sambuc {return reference(&__first_, __storage_type(1) << __pos);} 4584684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT 4594684ddb6SLionel Sambuc {return const_reference(&__first_, __storage_type(1) << __pos);} 4604684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT 4614684ddb6SLionel Sambuc {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 4624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT 4634684ddb6SLionel Sambuc {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} 4644684ddb6SLionel Sambuc 4654684ddb6SLionel Sambuc void operator&=(const __bitset& __v) _NOEXCEPT; 4664684ddb6SLionel Sambuc void operator|=(const __bitset& __v) _NOEXCEPT; 4674684ddb6SLionel Sambuc void operator^=(const __bitset& __v) _NOEXCEPT; 4684684ddb6SLionel Sambuc 4694684ddb6SLionel Sambuc void flip() _NOEXCEPT; 4704684ddb6SLionel Sambuc 4714684ddb6SLionel Sambuc unsigned long to_ulong() const; 4724684ddb6SLionel Sambuc unsigned long long to_ullong() const; 4734684ddb6SLionel Sambuc 4744684ddb6SLionel Sambuc bool all() const _NOEXCEPT; 4754684ddb6SLionel Sambuc bool any() const _NOEXCEPT; 4764684ddb6SLionel Sambuc 4774684ddb6SLionel Sambuc size_t __hash_code() const _NOEXCEPT; 4784684ddb6SLionel Sambuc}; 4794684ddb6SLionel Sambuc 4804684ddb6SLionel Sambuctemplate <size_t _Size> 4814684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4824684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 4834684ddb6SLionel Sambuc__bitset<1, _Size>::__bitset() _NOEXCEPT 4844684ddb6SLionel Sambuc : __first_(0) 4854684ddb6SLionel Sambuc{ 4864684ddb6SLionel Sambuc} 4874684ddb6SLionel Sambuc 4884684ddb6SLionel Sambuctemplate <size_t _Size> 4894684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4904684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 4914684ddb6SLionel Sambuc__bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT 4924684ddb6SLionel Sambuc : __first_(static_cast<__storage_type>(__v)) 4934684ddb6SLionel Sambuc{ 4944684ddb6SLionel Sambuc} 4954684ddb6SLionel Sambuc 4964684ddb6SLionel Sambuctemplate <size_t _Size> 4974684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4984684ddb6SLionel Sambucvoid 4994684ddb6SLionel Sambuc__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT 5004684ddb6SLionel Sambuc{ 5014684ddb6SLionel Sambuc __first_ &= __v.__first_; 5024684ddb6SLionel Sambuc} 5034684ddb6SLionel Sambuc 5044684ddb6SLionel Sambuctemplate <size_t _Size> 5054684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5064684ddb6SLionel Sambucvoid 5074684ddb6SLionel Sambuc__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT 5084684ddb6SLionel Sambuc{ 5094684ddb6SLionel Sambuc __first_ |= __v.__first_; 5104684ddb6SLionel Sambuc} 5114684ddb6SLionel Sambuc 5124684ddb6SLionel Sambuctemplate <size_t _Size> 5134684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5144684ddb6SLionel Sambucvoid 5154684ddb6SLionel Sambuc__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT 5164684ddb6SLionel Sambuc{ 5174684ddb6SLionel Sambuc __first_ ^= __v.__first_; 5184684ddb6SLionel Sambuc} 5194684ddb6SLionel Sambuc 5204684ddb6SLionel Sambuctemplate <size_t _Size> 5214684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5224684ddb6SLionel Sambucvoid 5234684ddb6SLionel Sambuc__bitset<1, _Size>::flip() _NOEXCEPT 5244684ddb6SLionel Sambuc{ 5254684ddb6SLionel Sambuc __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 5264684ddb6SLionel Sambuc __first_ = ~__first_; 5274684ddb6SLionel Sambuc __first_ &= __m; 5284684ddb6SLionel Sambuc} 5294684ddb6SLionel Sambuc 5304684ddb6SLionel Sambuctemplate <size_t _Size> 5314684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5324684ddb6SLionel Sambucunsigned long 5334684ddb6SLionel Sambuc__bitset<1, _Size>::to_ulong() const 5344684ddb6SLionel Sambuc{ 5354684ddb6SLionel Sambuc return __first_; 5364684ddb6SLionel Sambuc} 5374684ddb6SLionel Sambuc 5384684ddb6SLionel Sambuctemplate <size_t _Size> 5394684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5404684ddb6SLionel Sambucunsigned long long 5414684ddb6SLionel Sambuc__bitset<1, _Size>::to_ullong() const 5424684ddb6SLionel Sambuc{ 5434684ddb6SLionel Sambuc return __first_; 5444684ddb6SLionel Sambuc} 5454684ddb6SLionel Sambuc 5464684ddb6SLionel Sambuctemplate <size_t _Size> 5474684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5484684ddb6SLionel Sambucbool 5494684ddb6SLionel Sambuc__bitset<1, _Size>::all() const _NOEXCEPT 5504684ddb6SLionel Sambuc{ 5514684ddb6SLionel Sambuc __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 5524684ddb6SLionel Sambuc return !(~__first_ & __m); 5534684ddb6SLionel Sambuc} 5544684ddb6SLionel Sambuc 5554684ddb6SLionel Sambuctemplate <size_t _Size> 5564684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5574684ddb6SLionel Sambucbool 5584684ddb6SLionel Sambuc__bitset<1, _Size>::any() const _NOEXCEPT 5594684ddb6SLionel Sambuc{ 5604684ddb6SLionel Sambuc __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size); 5614684ddb6SLionel Sambuc return __first_ & __m; 5624684ddb6SLionel Sambuc} 5634684ddb6SLionel Sambuc 5644684ddb6SLionel Sambuctemplate <size_t _Size> 5654684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5664684ddb6SLionel Sambucsize_t 5674684ddb6SLionel Sambuc__bitset<1, _Size>::__hash_code() const _NOEXCEPT 5684684ddb6SLionel Sambuc{ 5694684ddb6SLionel Sambuc return __first_; 5704684ddb6SLionel Sambuc} 5714684ddb6SLionel Sambuc 5724684ddb6SLionel Sambuctemplate <> 5734684ddb6SLionel Sambucclass __bitset<0, 0> 5744684ddb6SLionel Sambuc{ 5754684ddb6SLionel Sambucpublic: 5764684ddb6SLionel Sambuc typedef ptrdiff_t difference_type; 5774684ddb6SLionel Sambuc typedef size_t size_type; 5784684ddb6SLionel Sambuc typedef size_type __storage_type; 5794684ddb6SLionel Sambucprotected: 5804684ddb6SLionel Sambuc typedef __bitset __self; 5814684ddb6SLionel Sambuc typedef __storage_type* __storage_pointer; 5824684ddb6SLionel Sambuc typedef const __storage_type* __const_storage_pointer; 5834684ddb6SLionel Sambuc static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); 5844684ddb6SLionel Sambuc 5854684ddb6SLionel Sambuc friend class __bit_reference<__bitset>; 5864684ddb6SLionel Sambuc friend class __bit_const_reference<__bitset>; 5874684ddb6SLionel Sambuc friend class __bit_iterator<__bitset, false>; 5884684ddb6SLionel Sambuc friend class __bit_iterator<__bitset, true>; 5894684ddb6SLionel Sambuc friend struct __bit_array<__bitset>; 5904684ddb6SLionel Sambuc 5914684ddb6SLionel Sambuc typedef __bit_reference<__bitset> reference; 5924684ddb6SLionel Sambuc typedef __bit_const_reference<__bitset> const_reference; 5934684ddb6SLionel Sambuc typedef __bit_iterator<__bitset, false> iterator; 5944684ddb6SLionel Sambuc typedef __bit_iterator<__bitset, true> const_iterator; 5954684ddb6SLionel Sambuc 5964684ddb6SLionel Sambuc _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 5974684ddb6SLionel Sambuc explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; 5984684ddb6SLionel Sambuc 5994684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT 6004684ddb6SLionel Sambuc {return reference(0, 1);} 6014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT 6024684ddb6SLionel Sambuc {return const_reference(0, 1);} 6034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT 6044684ddb6SLionel Sambuc {return iterator(0, 0);} 6054684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT 6064684ddb6SLionel Sambuc {return const_iterator(0, 0);} 6074684ddb6SLionel Sambuc 6084684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {} 6094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {} 6104684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset&) _NOEXCEPT {} 6114684ddb6SLionel Sambuc 6124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {} 6134684ddb6SLionel Sambuc 6144684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const {return 0;} 6154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const {return 0;} 6164684ddb6SLionel Sambuc 6174684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT {return true;} 6184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT {return false;} 6194684ddb6SLionel Sambuc 6204684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;} 6214684ddb6SLionel Sambuc}; 6224684ddb6SLionel Sambuc 6234684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6244684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 6254684ddb6SLionel Sambuc__bitset<0, 0>::__bitset() _NOEXCEPT 6264684ddb6SLionel Sambuc{ 6274684ddb6SLionel Sambuc} 6284684ddb6SLionel Sambuc 6294684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6304684ddb6SLionel Sambuc_LIBCPP_CONSTEXPR 6314684ddb6SLionel Sambuc__bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT 6324684ddb6SLionel Sambuc{ 6334684ddb6SLionel Sambuc} 6344684ddb6SLionel Sambuc 6354684ddb6SLionel Sambuctemplate <size_t _Size> class _LIBCPP_TYPE_VIS_ONLY bitset; 6364684ddb6SLionel Sambuctemplate <size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY hash<bitset<_Size> >; 6374684ddb6SLionel Sambuc 6384684ddb6SLionel Sambuctemplate <size_t _Size> 6394684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY bitset 6404684ddb6SLionel Sambuc : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> 6414684ddb6SLionel Sambuc{ 6424684ddb6SLionel Sambucpublic: 6434684ddb6SLionel Sambuc static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1; 6444684ddb6SLionel Sambuc typedef __bitset<__n_words, _Size> base; 6454684ddb6SLionel Sambuc 6464684ddb6SLionel Sambucpublic: 6474684ddb6SLionel Sambuc typedef typename base::reference reference; 6484684ddb6SLionel Sambuc typedef typename base::const_reference const_reference; 6494684ddb6SLionel Sambuc 6504684ddb6SLionel Sambuc // 23.3.5.1 constructors: 6514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} 6524684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 6534684ddb6SLionel Sambuc bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} 6544684ddb6SLionel Sambuc template<class _CharT> 6554684ddb6SLionel Sambuc explicit bitset(const _CharT* __str, 6564684ddb6SLionel Sambuc typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, 6574684ddb6SLionel Sambuc _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); 6584684ddb6SLionel Sambuc template<class _CharT, class _Traits, class _Allocator> 6594684ddb6SLionel Sambuc explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, 6604684ddb6SLionel Sambuc typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0, 6614684ddb6SLionel Sambuc typename basic_string<_CharT,_Traits,_Allocator>::size_type __n = 6624684ddb6SLionel Sambuc (basic_string<_CharT,_Traits,_Allocator>::npos), 6634684ddb6SLionel Sambuc _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); 6644684ddb6SLionel Sambuc 6654684ddb6SLionel Sambuc // 23.3.5.2 bitset operations: 6664684ddb6SLionel Sambuc bitset& operator&=(const bitset& __rhs) _NOEXCEPT; 6674684ddb6SLionel Sambuc bitset& operator|=(const bitset& __rhs) _NOEXCEPT; 6684684ddb6SLionel Sambuc bitset& operator^=(const bitset& __rhs) _NOEXCEPT; 6694684ddb6SLionel Sambuc bitset& operator<<=(size_t __pos) _NOEXCEPT; 6704684ddb6SLionel Sambuc bitset& operator>>=(size_t __pos) _NOEXCEPT; 6714684ddb6SLionel Sambuc bitset& set() _NOEXCEPT; 6724684ddb6SLionel Sambuc bitset& set(size_t __pos, bool __val = true); 6734684ddb6SLionel Sambuc bitset& reset() _NOEXCEPT; 6744684ddb6SLionel Sambuc bitset& reset(size_t __pos); 6754684ddb6SLionel Sambuc bitset operator~() const _NOEXCEPT; 6764684ddb6SLionel Sambuc bitset& flip() _NOEXCEPT; 6774684ddb6SLionel Sambuc bitset& flip(size_t __pos); 6784684ddb6SLionel Sambuc 6794684ddb6SLionel Sambuc // element access: 6804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 6814684ddb6SLionel Sambuc const_reference operator[](size_t __p) const {return base::__make_ref(__p);} 6824684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);} 6834684ddb6SLionel Sambuc unsigned long to_ulong() const; 6844684ddb6SLionel Sambuc unsigned long long to_ullong() const; 6854684ddb6SLionel Sambuc template <class _CharT, class _Traits, class _Allocator> 6864684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'), 6874684ddb6SLionel Sambuc _CharT __one = _CharT('1')) const; 6884684ddb6SLionel Sambuc template <class _CharT, class _Traits> 6894684ddb6SLionel Sambuc basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), 6904684ddb6SLionel Sambuc _CharT __one = _CharT('1')) const; 6914684ddb6SLionel Sambuc template <class _CharT> 6924684ddb6SLionel Sambuc basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), 6934684ddb6SLionel Sambuc _CharT __one = _CharT('1')) const; 6944684ddb6SLionel Sambuc basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0', 6954684ddb6SLionel Sambuc char __one = '1') const; 6964684ddb6SLionel Sambuc size_t count() const _NOEXCEPT; 6974684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;} 6984684ddb6SLionel Sambuc bool operator==(const bitset& __rhs) const _NOEXCEPT; 6994684ddb6SLionel Sambuc bool operator!=(const bitset& __rhs) const _NOEXCEPT; 7004684ddb6SLionel Sambuc bool test(size_t __pos) const; 7014684ddb6SLionel Sambuc bool all() const _NOEXCEPT; 7024684ddb6SLionel Sambuc bool any() const _NOEXCEPT; 7034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();} 7044684ddb6SLionel Sambuc bitset operator<<(size_t __pos) const _NOEXCEPT; 7054684ddb6SLionel Sambuc bitset operator>>(size_t __pos) const _NOEXCEPT; 7064684ddb6SLionel Sambuc 7074684ddb6SLionel Sambucprivate: 7084684ddb6SLionel Sambuc 7094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 7104684ddb6SLionel Sambuc size_t __hash_code() const _NOEXCEPT {return base::__hash_code();} 7114684ddb6SLionel Sambuc 7124684ddb6SLionel Sambuc friend struct hash<bitset>; 7134684ddb6SLionel Sambuc}; 7144684ddb6SLionel Sambuc 7154684ddb6SLionel Sambuctemplate <size_t _Size> 7164684ddb6SLionel Sambuctemplate<class _CharT> 7174684ddb6SLionel Sambucbitset<_Size>::bitset(const _CharT* __str, 7184684ddb6SLionel Sambuc typename basic_string<_CharT>::size_type __n, 7194684ddb6SLionel Sambuc _CharT __zero, _CharT __one) 7204684ddb6SLionel Sambuc{ 7214684ddb6SLionel Sambuc size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str)); 7224684ddb6SLionel Sambuc for (size_t __i = 0; __i < __rlen; ++__i) 7234684ddb6SLionel Sambuc if (__str[__i] != __zero && __str[__i] != __one) 7244684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 7254684ddb6SLionel Sambuc throw invalid_argument("bitset string ctor has invalid argument"); 7264684ddb6SLionel Sambuc#else 7274684ddb6SLionel Sambuc assert(!"bitset string ctor has invalid argument"); 7284684ddb6SLionel Sambuc#endif 7294684ddb6SLionel Sambuc size_t _Mp = _VSTD::min(__rlen, _Size); 7304684ddb6SLionel Sambuc size_t __i = 0; 7314684ddb6SLionel Sambuc for (; __i < _Mp; ++__i) 7324684ddb6SLionel Sambuc { 7334684ddb6SLionel Sambuc _CharT __c = __str[_Mp - 1 - __i]; 7344684ddb6SLionel Sambuc if (__c == __zero) 7354684ddb6SLionel Sambuc (*this)[__i] = false; 7364684ddb6SLionel Sambuc else 7374684ddb6SLionel Sambuc (*this)[__i] = true; 7384684ddb6SLionel Sambuc } 7394684ddb6SLionel Sambuc _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false); 7404684ddb6SLionel Sambuc} 7414684ddb6SLionel Sambuc 7424684ddb6SLionel Sambuctemplate <size_t _Size> 7434684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 7444684ddb6SLionel Sambucbitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, 7454684ddb6SLionel Sambuc typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos, 7464684ddb6SLionel Sambuc typename basic_string<_CharT,_Traits,_Allocator>::size_type __n, 7474684ddb6SLionel Sambuc _CharT __zero, _CharT __one) 7484684ddb6SLionel Sambuc{ 7494684ddb6SLionel Sambuc if (__pos > __str.size()) 7504684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 7514684ddb6SLionel Sambuc throw out_of_range("bitset string pos out of range"); 7524684ddb6SLionel Sambuc#else 7534684ddb6SLionel Sambuc assert(!"bitset string pos out of range"); 7544684ddb6SLionel Sambuc#endif 7554684ddb6SLionel Sambuc size_t __rlen = _VSTD::min(__n, __str.size() - __pos); 7564684ddb6SLionel Sambuc for (size_t __i = __pos; __i < __pos + __rlen; ++__i) 7574684ddb6SLionel Sambuc if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one)) 7584684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 7594684ddb6SLionel Sambuc throw invalid_argument("bitset string ctor has invalid argument"); 7604684ddb6SLionel Sambuc#else 7614684ddb6SLionel Sambuc assert(!"bitset string ctor has invalid argument"); 7624684ddb6SLionel Sambuc#endif 7634684ddb6SLionel Sambuc size_t _Mp = _VSTD::min(__rlen, _Size); 7644684ddb6SLionel Sambuc size_t __i = 0; 7654684ddb6SLionel Sambuc for (; __i < _Mp; ++__i) 7664684ddb6SLionel Sambuc { 7674684ddb6SLionel Sambuc _CharT __c = __str[__pos + _Mp - 1 - __i]; 7684684ddb6SLionel Sambuc if (_Traits::eq(__c, __zero)) 7694684ddb6SLionel Sambuc (*this)[__i] = false; 7704684ddb6SLionel Sambuc else 7714684ddb6SLionel Sambuc (*this)[__i] = true; 7724684ddb6SLionel Sambuc } 7734684ddb6SLionel Sambuc _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false); 7744684ddb6SLionel Sambuc} 7754684ddb6SLionel Sambuc 7764684ddb6SLionel Sambuctemplate <size_t _Size> 7774684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7784684ddb6SLionel Sambucbitset<_Size>& 7794684ddb6SLionel Sambucbitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT 7804684ddb6SLionel Sambuc{ 7814684ddb6SLionel Sambuc base::operator&=(__rhs); 7824684ddb6SLionel Sambuc return *this; 7834684ddb6SLionel Sambuc} 7844684ddb6SLionel Sambuc 7854684ddb6SLionel Sambuctemplate <size_t _Size> 7864684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7874684ddb6SLionel Sambucbitset<_Size>& 7884684ddb6SLionel Sambucbitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT 7894684ddb6SLionel Sambuc{ 7904684ddb6SLionel Sambuc base::operator|=(__rhs); 7914684ddb6SLionel Sambuc return *this; 7924684ddb6SLionel Sambuc} 7934684ddb6SLionel Sambuc 7944684ddb6SLionel Sambuctemplate <size_t _Size> 7954684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7964684ddb6SLionel Sambucbitset<_Size>& 7974684ddb6SLionel Sambucbitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT 7984684ddb6SLionel Sambuc{ 7994684ddb6SLionel Sambuc base::operator^=(__rhs); 8004684ddb6SLionel Sambuc return *this; 8014684ddb6SLionel Sambuc} 8024684ddb6SLionel Sambuc 8034684ddb6SLionel Sambuctemplate <size_t _Size> 8044684ddb6SLionel Sambucbitset<_Size>& 8054684ddb6SLionel Sambucbitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT 8064684ddb6SLionel Sambuc{ 8074684ddb6SLionel Sambuc __pos = _VSTD::min(__pos, _Size); 8084684ddb6SLionel Sambuc _VSTD::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size)); 8094684ddb6SLionel Sambuc _VSTD::fill_n(base::__make_iter(0), __pos, false); 8104684ddb6SLionel Sambuc return *this; 8114684ddb6SLionel Sambuc} 8124684ddb6SLionel Sambuc 8134684ddb6SLionel Sambuctemplate <size_t _Size> 8144684ddb6SLionel Sambucbitset<_Size>& 8154684ddb6SLionel Sambucbitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT 8164684ddb6SLionel Sambuc{ 8174684ddb6SLionel Sambuc __pos = _VSTD::min(__pos, _Size); 8184684ddb6SLionel Sambuc _VSTD::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0)); 8194684ddb6SLionel Sambuc _VSTD::fill_n(base::__make_iter(_Size - __pos), __pos, false); 8204684ddb6SLionel Sambuc return *this; 8214684ddb6SLionel Sambuc} 8224684ddb6SLionel Sambuc 8234684ddb6SLionel Sambuctemplate <size_t _Size> 8244684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8254684ddb6SLionel Sambucbitset<_Size>& 8264684ddb6SLionel Sambucbitset<_Size>::set() _NOEXCEPT 8274684ddb6SLionel Sambuc{ 8284684ddb6SLionel Sambuc _VSTD::fill_n(base::__make_iter(0), _Size, true); 8294684ddb6SLionel Sambuc return *this; 8304684ddb6SLionel Sambuc} 8314684ddb6SLionel Sambuc 8324684ddb6SLionel Sambuctemplate <size_t _Size> 8334684ddb6SLionel Sambucbitset<_Size>& 8344684ddb6SLionel Sambucbitset<_Size>::set(size_t __pos, bool __val) 8354684ddb6SLionel Sambuc{ 8364684ddb6SLionel Sambuc if (__pos >= _Size) 8374684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 8384684ddb6SLionel Sambuc throw out_of_range("bitset set argument out of range"); 8394684ddb6SLionel Sambuc#else 8404684ddb6SLionel Sambuc assert(!"bitset set argument out of range"); 8414684ddb6SLionel Sambuc#endif 8424684ddb6SLionel Sambuc (*this)[__pos] = __val; 8434684ddb6SLionel Sambuc return *this; 8444684ddb6SLionel Sambuc} 8454684ddb6SLionel Sambuc 8464684ddb6SLionel Sambuctemplate <size_t _Size> 8474684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8484684ddb6SLionel Sambucbitset<_Size>& 8494684ddb6SLionel Sambucbitset<_Size>::reset() _NOEXCEPT 8504684ddb6SLionel Sambuc{ 8514684ddb6SLionel Sambuc _VSTD::fill_n(base::__make_iter(0), _Size, false); 8524684ddb6SLionel Sambuc return *this; 8534684ddb6SLionel Sambuc} 8544684ddb6SLionel Sambuc 8554684ddb6SLionel Sambuctemplate <size_t _Size> 8564684ddb6SLionel Sambucbitset<_Size>& 8574684ddb6SLionel Sambucbitset<_Size>::reset(size_t __pos) 8584684ddb6SLionel Sambuc{ 8594684ddb6SLionel Sambuc if (__pos >= _Size) 8604684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 8614684ddb6SLionel Sambuc throw out_of_range("bitset reset argument out of range"); 8624684ddb6SLionel Sambuc#else 8634684ddb6SLionel Sambuc assert(!"bitset reset argument out of range"); 8644684ddb6SLionel Sambuc#endif 8654684ddb6SLionel Sambuc (*this)[__pos] = false; 8664684ddb6SLionel Sambuc return *this; 8674684ddb6SLionel Sambuc} 8684684ddb6SLionel Sambuc 8694684ddb6SLionel Sambuctemplate <size_t _Size> 8704684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8714684ddb6SLionel Sambucbitset<_Size> 8724684ddb6SLionel Sambucbitset<_Size>::operator~() const _NOEXCEPT 8734684ddb6SLionel Sambuc{ 8744684ddb6SLionel Sambuc bitset __x(*this); 8754684ddb6SLionel Sambuc __x.flip(); 8764684ddb6SLionel Sambuc return __x; 8774684ddb6SLionel Sambuc} 8784684ddb6SLionel Sambuc 8794684ddb6SLionel Sambuctemplate <size_t _Size> 8804684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8814684ddb6SLionel Sambucbitset<_Size>& 8824684ddb6SLionel Sambucbitset<_Size>::flip() _NOEXCEPT 8834684ddb6SLionel Sambuc{ 8844684ddb6SLionel Sambuc base::flip(); 8854684ddb6SLionel Sambuc return *this; 8864684ddb6SLionel Sambuc} 8874684ddb6SLionel Sambuc 8884684ddb6SLionel Sambuctemplate <size_t _Size> 8894684ddb6SLionel Sambucbitset<_Size>& 8904684ddb6SLionel Sambucbitset<_Size>::flip(size_t __pos) 8914684ddb6SLionel Sambuc{ 8924684ddb6SLionel Sambuc if (__pos >= _Size) 8934684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 8944684ddb6SLionel Sambuc throw out_of_range("bitset flip argument out of range"); 8954684ddb6SLionel Sambuc#else 8964684ddb6SLionel Sambuc assert(!"bitset flip argument out of range"); 8974684ddb6SLionel Sambuc#endif 8984684ddb6SLionel Sambuc reference r = base::__make_ref(__pos); 8994684ddb6SLionel Sambuc r = ~r; 9004684ddb6SLionel Sambuc return *this; 9014684ddb6SLionel Sambuc} 9024684ddb6SLionel Sambuc 9034684ddb6SLionel Sambuctemplate <size_t _Size> 9044684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9054684ddb6SLionel Sambucunsigned long 9064684ddb6SLionel Sambucbitset<_Size>::to_ulong() const 9074684ddb6SLionel Sambuc{ 9084684ddb6SLionel Sambuc return base::to_ulong(); 9094684ddb6SLionel Sambuc} 9104684ddb6SLionel Sambuc 9114684ddb6SLionel Sambuctemplate <size_t _Size> 9124684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9134684ddb6SLionel Sambucunsigned long long 9144684ddb6SLionel Sambucbitset<_Size>::to_ullong() const 9154684ddb6SLionel Sambuc{ 9164684ddb6SLionel Sambuc return base::to_ullong(); 9174684ddb6SLionel Sambuc} 9184684ddb6SLionel Sambuc 9194684ddb6SLionel Sambuctemplate <size_t _Size> 9204684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 9214684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 9224684ddb6SLionel Sambucbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 9234684ddb6SLionel Sambuc{ 9244684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero); 9254684ddb6SLionel Sambuc for (size_t __i = 0; __i < _Size; ++__i) 9264684ddb6SLionel Sambuc { 9274684ddb6SLionel Sambuc if ((*this)[__i]) 9284684ddb6SLionel Sambuc __r[_Size - 1 - __i] = __one; 9294684ddb6SLionel Sambuc } 9304684ddb6SLionel Sambuc return __r; 9314684ddb6SLionel Sambuc} 9324684ddb6SLionel Sambuc 9334684ddb6SLionel Sambuctemplate <size_t _Size> 9344684ddb6SLionel Sambuctemplate <class _CharT, class _Traits> 9354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9364684ddb6SLionel Sambucbasic_string<_CharT, _Traits, allocator<_CharT> > 9374684ddb6SLionel Sambucbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 9384684ddb6SLionel Sambuc{ 9394684ddb6SLionel Sambuc return to_string<_CharT, _Traits, allocator<_CharT> >(__zero, __one); 9404684ddb6SLionel Sambuc} 9414684ddb6SLionel Sambuc 9424684ddb6SLionel Sambuctemplate <size_t _Size> 9434684ddb6SLionel Sambuctemplate <class _CharT> 9444684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9454684ddb6SLionel Sambucbasic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > 9464684ddb6SLionel Sambucbitset<_Size>::to_string(_CharT __zero, _CharT __one) const 9474684ddb6SLionel Sambuc{ 9484684ddb6SLionel Sambuc return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(__zero, __one); 9494684ddb6SLionel Sambuc} 9504684ddb6SLionel Sambuc 9514684ddb6SLionel Sambuctemplate <size_t _Size> 9524684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9534684ddb6SLionel Sambucbasic_string<char, char_traits<char>, allocator<char> > 9544684ddb6SLionel Sambucbitset<_Size>::to_string(char __zero, char __one) const 9554684ddb6SLionel Sambuc{ 9564684ddb6SLionel Sambuc return to_string<char, char_traits<char>, allocator<char> >(__zero, __one); 9574684ddb6SLionel Sambuc} 9584684ddb6SLionel Sambuc 9594684ddb6SLionel Sambuctemplate <size_t _Size> 9604684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9614684ddb6SLionel Sambucsize_t 9624684ddb6SLionel Sambucbitset<_Size>::count() const _NOEXCEPT 9634684ddb6SLionel Sambuc{ 9644684ddb6SLionel Sambuc return static_cast<size_t>(_VSTD::count(base::__make_iter(0), base::__make_iter(_Size), true)); 9654684ddb6SLionel Sambuc} 9664684ddb6SLionel Sambuc 9674684ddb6SLionel Sambuctemplate <size_t _Size> 9684684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9694684ddb6SLionel Sambucbool 9704684ddb6SLionel Sambucbitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT 9714684ddb6SLionel Sambuc{ 9724684ddb6SLionel Sambuc return _VSTD::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0)); 9734684ddb6SLionel Sambuc} 9744684ddb6SLionel Sambuc 9754684ddb6SLionel Sambuctemplate <size_t _Size> 9764684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9774684ddb6SLionel Sambucbool 9784684ddb6SLionel Sambucbitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT 9794684ddb6SLionel Sambuc{ 9804684ddb6SLionel Sambuc return !(*this == __rhs); 9814684ddb6SLionel Sambuc} 9824684ddb6SLionel Sambuc 9834684ddb6SLionel Sambuctemplate <size_t _Size> 9844684ddb6SLionel Sambucbool 9854684ddb6SLionel Sambucbitset<_Size>::test(size_t __pos) const 9864684ddb6SLionel Sambuc{ 9874684ddb6SLionel Sambuc if (__pos >= _Size) 9884684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 9894684ddb6SLionel Sambuc throw out_of_range("bitset test argument out of range"); 9904684ddb6SLionel Sambuc#else 9914684ddb6SLionel Sambuc assert(!"bitset test argument out of range"); 9924684ddb6SLionel Sambuc#endif 9934684ddb6SLionel Sambuc return (*this)[__pos]; 9944684ddb6SLionel Sambuc} 9954684ddb6SLionel Sambuc 9964684ddb6SLionel Sambuctemplate <size_t _Size> 9974684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9984684ddb6SLionel Sambucbool 9994684ddb6SLionel Sambucbitset<_Size>::all() const _NOEXCEPT 10004684ddb6SLionel Sambuc{ 10014684ddb6SLionel Sambuc return base::all(); 10024684ddb6SLionel Sambuc} 10034684ddb6SLionel Sambuc 10044684ddb6SLionel Sambuctemplate <size_t _Size> 10054684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10064684ddb6SLionel Sambucbool 10074684ddb6SLionel Sambucbitset<_Size>::any() const _NOEXCEPT 10084684ddb6SLionel Sambuc{ 10094684ddb6SLionel Sambuc return base::any(); 10104684ddb6SLionel Sambuc} 10114684ddb6SLionel Sambuc 10124684ddb6SLionel Sambuctemplate <size_t _Size> 10134684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10144684ddb6SLionel Sambucbitset<_Size> 10154684ddb6SLionel Sambucbitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT 10164684ddb6SLionel Sambuc{ 10174684ddb6SLionel Sambuc bitset __r = *this; 10184684ddb6SLionel Sambuc __r <<= __pos; 10194684ddb6SLionel Sambuc return __r; 10204684ddb6SLionel Sambuc} 10214684ddb6SLionel Sambuc 10224684ddb6SLionel Sambuctemplate <size_t _Size> 10234684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10244684ddb6SLionel Sambucbitset<_Size> 10254684ddb6SLionel Sambucbitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT 10264684ddb6SLionel Sambuc{ 10274684ddb6SLionel Sambuc bitset __r = *this; 10284684ddb6SLionel Sambuc __r >>= __pos; 10294684ddb6SLionel Sambuc return __r; 10304684ddb6SLionel Sambuc} 10314684ddb6SLionel Sambuc 10324684ddb6SLionel Sambuctemplate <size_t _Size> 10334684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10344684ddb6SLionel Sambucbitset<_Size> 10354684ddb6SLionel Sambucoperator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 10364684ddb6SLionel Sambuc{ 10374684ddb6SLionel Sambuc bitset<_Size> __r = __x; 10384684ddb6SLionel Sambuc __r &= __y; 10394684ddb6SLionel Sambuc return __r; 10404684ddb6SLionel Sambuc} 10414684ddb6SLionel Sambuc 10424684ddb6SLionel Sambuctemplate <size_t _Size> 10434684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10444684ddb6SLionel Sambucbitset<_Size> 10454684ddb6SLionel Sambucoperator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 10464684ddb6SLionel Sambuc{ 10474684ddb6SLionel Sambuc bitset<_Size> __r = __x; 10484684ddb6SLionel Sambuc __r |= __y; 10494684ddb6SLionel Sambuc return __r; 10504684ddb6SLionel Sambuc} 10514684ddb6SLionel Sambuc 10524684ddb6SLionel Sambuctemplate <size_t _Size> 10534684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 10544684ddb6SLionel Sambucbitset<_Size> 10554684ddb6SLionel Sambucoperator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT 10564684ddb6SLionel Sambuc{ 10574684ddb6SLionel Sambuc bitset<_Size> __r = __x; 10584684ddb6SLionel Sambuc __r ^= __y; 10594684ddb6SLionel Sambuc return __r; 10604684ddb6SLionel Sambuc} 10614684ddb6SLionel Sambuc 10624684ddb6SLionel Sambuctemplate <size_t _Size> 10634684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<bitset<_Size> > 10644684ddb6SLionel Sambuc : public unary_function<bitset<_Size>, size_t> 10654684ddb6SLionel Sambuc{ 10664684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 10674684ddb6SLionel Sambuc size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT 10684684ddb6SLionel Sambuc {return __bs.__hash_code();} 10694684ddb6SLionel Sambuc}; 10704684ddb6SLionel Sambuc 10714684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, size_t _Size> 10724684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 10734684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x); 10744684ddb6SLionel Sambuc 10754684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, size_t _Size> 10764684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& 10774684ddb6SLionel Sambucoperator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x); 10784684ddb6SLionel Sambuc 10794684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD 10804684ddb6SLionel Sambuc 10814684ddb6SLionel Sambuc#endif // _LIBCPP_BITSET 1082