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