diff options
Diffstat (limited to 'system/include/libcxx/bitset')
-rw-r--r-- | system/include/libcxx/bitset | 95 |
1 files changed, 65 insertions, 30 deletions
diff --git a/system/include/libcxx/bitset b/system/include/libcxx/bitset index 4d9efd93..06fd729e 100644 --- a/system/include/libcxx/bitset +++ b/system/include/libcxx/bitset @@ -113,7 +113,9 @@ template <size_t N> struct hash<std::bitset<N>>; */ +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header +#endif #include <__config> #include <__bit_reference> @@ -127,6 +129,8 @@ template <size_t N> struct hash<std::bitset<N>>; #include <cassert> #endif +#include <__undef_min_max> + _LIBCPP_BEGIN_NAMESPACE_STD template <size_t _N_words, size_t _Size> @@ -144,9 +148,9 @@ class __bitset public: typedef ptrdiff_t difference_type; typedef size_t size_type; + typedef size_type __storage_type; protected: typedef __bitset __self; - typedef size_type __storage_type; typedef __storage_type* __storage_pointer; typedef const __storage_type* __const_storage_pointer; static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); @@ -155,7 +159,7 @@ protected: friend class __bit_const_reference<__bitset>; friend class __bit_iterator<__bitset, false>; friend class __bit_iterator<__bitset, true>; - friend class __bit_array<__bitset>; + friend struct __bit_array<__bitset>; __storage_type __first_[_N_words]; @@ -164,12 +168,12 @@ protected: typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; - __bitset() _NOEXCEPT; - explicit __bitset(unsigned long long __v) _NOEXCEPT; + _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY const_reference __make_ref(size_t __pos) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} @@ -190,8 +194,10 @@ protected: bool any() const _NOEXCEPT; size_t __hash_code() const _NOEXCEPT; private: +#ifdef _LIBCPP_HAS_NO_CONSTEXPR void __init(unsigned long long __v, false_type) _NOEXCEPT; void __init(unsigned long long __v, true_type) _NOEXCEPT; +#endif // _LIBCPP_HAS_NO_CONSTEXPR unsigned long to_ulong(false_type) const; unsigned long to_ulong(true_type) const; unsigned long long to_ullong(false_type) const; @@ -202,14 +208,22 @@ private: template <size_t _N_words, size_t _Size> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT +#ifndef _LIBCPP_HAS_NO_CONSTEXPR + : __first_{0} +#endif { +#ifdef _LIBCPP_HAS_NO_CONSTEXPR _VSTD::fill_n(__first_, _N_words, __storage_type(0)); +#endif } +#ifdef _LIBCPP_HAS_NO_CONSTEXPR + template <size_t _N_words, size_t _Size> void -__bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) +__bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT { __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)]; for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word) @@ -222,17 +236,31 @@ __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) template <size_t _N_words, size_t _Size> inline _LIBCPP_INLINE_VISIBILITY void -__bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) +__bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT { __first_[0] = __v; _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0)); } +#endif // _LIBCPP_HAS_NO_CONSTEXPR + template <size_t _N_words, size_t _Size> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT +#ifndef _LIBCPP_HAS_NO_CONSTEXPR +#if __SIZE_WIDTH__ == 64 + : __first_{__v} +#elif __SIZE_WIDTH__ == 32 + : __first_{__v, __v >> __bits_per_word} +#elif +#error This constructor has not been ported to this platform +#endif +#endif { +#ifdef _LIBCPP_HAS_NO_CONSTEXPR __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>()); +#endif } template <size_t _N_words, size_t _Size> @@ -402,9 +430,9 @@ class __bitset<1, _Size> public: typedef ptrdiff_t difference_type; typedef size_t size_type; + typedef size_type __storage_type; protected: typedef __bitset __self; - typedef size_type __storage_type; typedef __storage_type* __storage_pointer; typedef const __storage_type* __const_storage_pointer; static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); @@ -413,7 +441,7 @@ protected: friend class __bit_const_reference<__bitset>; friend class __bit_iterator<__bitset, false>; friend class __bit_iterator<__bitset, true>; - friend class __bit_array<__bitset>; + friend struct __bit_array<__bitset>; __storage_type __first_; @@ -422,12 +450,12 @@ protected: typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; - __bitset() _NOEXCEPT; - explicit __bitset(unsigned long long __v) _NOEXCEPT; + _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT {return reference(&__first_, __storage_type(1) << __pos);} - _LIBCPP_INLINE_VISIBILITY const_reference __make_ref(size_t __pos) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT {return const_reference(&__first_, __storage_type(1) << __pos);} _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} @@ -451,6 +479,7 @@ protected: template <size_t _Size> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0) { @@ -458,6 +487,7 @@ __bitset<1, _Size>::__bitset() _NOEXCEPT template <size_t _Size> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT : __first_(static_cast<__storage_type>(__v)) { @@ -545,9 +575,9 @@ class __bitset<0, 0> public: typedef ptrdiff_t difference_type; typedef size_t size_type; + typedef size_type __storage_type; protected: typedef __bitset __self; - typedef size_type __storage_type; typedef __storage_type* __storage_pointer; typedef const __storage_type* __const_storage_pointer; static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); @@ -556,23 +586,23 @@ protected: friend class __bit_const_reference<__bitset>; friend class __bit_iterator<__bitset, false>; friend class __bit_iterator<__bitset, true>; - friend class __bit_array<__bitset>; + friend struct __bit_array<__bitset>; typedef __bit_reference<__bitset> reference; typedef __bit_const_reference<__bitset> const_reference; typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; - __bitset() _NOEXCEPT; - explicit __bitset(unsigned long long) _NOEXCEPT; + _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT {return reference(0, 1);} - _LIBCPP_INLINE_VISIBILITY const_reference __make_ref(size_t) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT {return const_reference(0, 1);} - _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT {return iterator(0, 0);} - _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT {return const_iterator(0, 0);} _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {} @@ -591,22 +621,25 @@ protected: }; inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT { } inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT { } -template <size_t _Size> class bitset; +template <size_t _Size> class _LIBCPP_VISIBLE bitset; template <size_t _Size> struct hash<bitset<_Size> >; template <size_t _Size> class _LIBCPP_VISIBLE bitset : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> { +public: static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1; typedef __bitset<__n_words, _Size> base; @@ -615,8 +648,9 @@ public: typedef typename base::const_reference const_reference; // 23.3.5.1 constructors: - /*constexpr*/ _LIBCPP_INLINE_VISIBILITY bitset() _NOEXCEPT {} - /*constexpr*/ _LIBCPP_INLINE_VISIBILITY bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} template<class _CharT> explicit bitset(const _CharT* __str, typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, @@ -643,7 +677,8 @@ public: bitset& flip(size_t __pos); // element access: - _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_t __p) const {return base::__make_ref(__p);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + const_reference operator[](size_t __p) const {return base::__make_ref(__p);} _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);} unsigned long to_ulong() const; unsigned long long to_ullong() const; @@ -659,7 +694,7 @@ public: basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0', char __one = '1') const; size_t count() const _NOEXCEPT; - /*constexpr*/ _LIBCPP_INLINE_VISIBILITY size_t size() const _NOEXCEPT {return _Size;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;} bool operator==(const bitset& __rhs) const _NOEXCEPT; bool operator!=(const bitset& __rhs) const _NOEXCEPT; bool test(size_t __pos) const; @@ -691,11 +726,11 @@ bitset<_Size>::bitset(const _CharT* __str, #else assert(!"bitset string ctor has invalid argument"); #endif - size_t _M = _VSTD::min(__rlen, _Size); + size_t _Mp = _VSTD::min(__rlen, _Size); size_t __i = 0; - for (; __i < _M; ++__i) + for (; __i < _Mp; ++__i) { - _CharT __c = __str[_M - 1 - __i]; + _CharT __c = __str[_Mp - 1 - __i]; if (__c == __zero) (*this)[__i] = false; else @@ -725,11 +760,11 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, #else assert(!"bitset string ctor has invalid argument"); #endif - size_t _M = _VSTD::min(__rlen, _Size); + size_t _Mp = _VSTD::min(__rlen, _Size); size_t __i = 0; - for (; __i < _M; ++__i) + for (; __i < _Mp; ++__i) { - _CharT __c = __str[__pos + _M - 1 - __i]; + _CharT __c = __str[__pos + _Mp - 1 - __i]; if (_Traits::eq(__c, __zero)) (*this)[__i] = false; else |