comparison libcxx/include/bitset @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
112 112
113 */ 113 */
114 114
115 #include <__config> 115 #include <__config>
116 #include <__bit_reference> 116 #include <__bit_reference>
117 #include <__functional_base>
118 #include <climits>
117 #include <cstddef> 119 #include <cstddef>
118 #include <climits> 120 #include <iosfwd>
121 #include <stdexcept>
119 #include <string> 122 #include <string>
120 #include <stdexcept>
121 #include <iosfwd>
122 #include <__functional_base>
123 123
124 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 124 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
125 #pragma GCC system_header 125 #pragma GCC system_header
126 #endif 126 #endif
127 127
200 private: 200 private:
201 #ifdef _LIBCPP_CXX03_LANG 201 #ifdef _LIBCPP_CXX03_LANG
202 void __init(unsigned long long __v, false_type) _NOEXCEPT; 202 void __init(unsigned long long __v, false_type) _NOEXCEPT;
203 _LIBCPP_INLINE_VISIBILITY 203 _LIBCPP_INLINE_VISIBILITY
204 void __init(unsigned long long __v, true_type) _NOEXCEPT; 204 void __init(unsigned long long __v, true_type) _NOEXCEPT;
205 #endif // _LIBCPP_CXX03_LANG 205 #endif // _LIBCPP_CXX03_LANG
206 unsigned long to_ulong(false_type) const; 206 unsigned long to_ulong(false_type) const;
207 _LIBCPP_INLINE_VISIBILITY 207 _LIBCPP_INLINE_VISIBILITY
208 unsigned long to_ulong(true_type) const; 208 unsigned long to_ulong(true_type) const;
209 unsigned long long to_ullong(false_type) const; 209 unsigned long long to_ullong(false_type) const;
210 _LIBCPP_INLINE_VISIBILITY 210 _LIBCPP_INLINE_VISIBILITY
256 __first_[0] &= ( 1ULL << _Size ) - 1; 256 __first_[0] &= ( 1ULL << _Size ) - 1;
257 257
258 _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0)); 258 _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0));
259 } 259 }
260 260
261 #endif // _LIBCPP_CXX03_LANG 261 #endif // _LIBCPP_CXX03_LANG
262 262
263 template <size_t _N_words, size_t _Size> 263 template <size_t _N_words, size_t _Size>
264 inline 264 inline
265 _LIBCPP_CONSTEXPR 265 _LIBCPP_CONSTEXPR
266 __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT 266 __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
378 template <size_t _N_words, size_t _Size> 378 template <size_t _N_words, size_t _Size>
379 unsigned long long 379 unsigned long long
380 __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const 380 __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
381 { 381 {
382 unsigned long long __r = __first_[0]; 382 unsigned long long __r = __first_[0];
383 for (std::size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i) 383 for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
384 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT); 384 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
385 return __r; 385 return __r;
386 } 386 }
387 387
388 template <size_t _N_words, size_t _Size> 388 template <size_t _N_words, size_t _Size>
623 _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; 623 _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
624 _LIBCPP_INLINE_VISIBILITY 624 _LIBCPP_INLINE_VISIBILITY
625 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; 625 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
626 626
627 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT 627 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
628 {return reference(0, 1);} 628 {return reference(nullptr, 1);}
629 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT 629 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
630 {return const_reference(0, 1);} 630 {return const_reference(nullptr, 1);}
631 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT 631 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT
632 {return iterator(0, 0);} 632 {return iterator(nullptr, 0);}
633 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT 633 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT
634 {return const_iterator(0, 0);} 634 {return const_iterator(nullptr, 0);}
635 635
636 _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {} 636 _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}
637 _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {} 637 _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}
638 _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset&) _NOEXCEPT {} 638 _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset&) _NOEXCEPT {}
639 639
773 size_t _Mp = _VSTD::min(__rlen, _Size); 773 size_t _Mp = _VSTD::min(__rlen, _Size);
774 size_t __i = 0; 774 size_t __i = 0;
775 for (; __i < _Mp; ++__i) 775 for (; __i < _Mp; ++__i)
776 { 776 {
777 _CharT __c = __str[_Mp - 1 - __i]; 777 _CharT __c = __str[_Mp - 1 - __i];
778 if (__c == __zero) 778 (*this)[__i] = (__c == __one);
779 (*this)[__i] = false;
780 else
781 (*this)[__i] = true;
782 } 779 }
783 _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false); 780 _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
784 } 781 }
785 782
786 template <size_t _Size> 783 template <size_t _Size>
801 size_t _Mp = _VSTD::min(__rlen, _Size); 798 size_t _Mp = _VSTD::min(__rlen, _Size);
802 size_t __i = 0; 799 size_t __i = 0;
803 for (; __i < _Mp; ++__i) 800 for (; __i < _Mp; ++__i)
804 { 801 {
805 _CharT __c = __str[__pos + _Mp - 1 - __i]; 802 _CharT __c = __str[__pos + _Mp - 1 - __i];
806 if (_Traits::eq(__c, __zero)) 803 (*this)[__i] = _Traits::eq(__c, __one);
807 (*this)[__i] = false;
808 else
809 (*this)[__i] = true;
810 } 804 }
811 _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false); 805 _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
812 } 806 }
813 807
814 template <size_t _Size> 808 template <size_t _Size>
988 template <size_t _Size> 982 template <size_t _Size>
989 inline 983 inline
990 size_t 984 size_t
991 bitset<_Size>::count() const _NOEXCEPT 985 bitset<_Size>::count() const _NOEXCEPT
992 { 986 {
993 return static_cast<size_t>(__count_bool_true(base::__make_iter(0), _Size)); 987 return static_cast<size_t>(_VSTD::__count_bool_true(base::__make_iter(0), _Size));
994 } 988 }
995 989
996 template <size_t _Size> 990 template <size_t _Size>
997 inline 991 inline
998 bool 992 bool
1104 1098
1105 _LIBCPP_END_NAMESPACE_STD 1099 _LIBCPP_END_NAMESPACE_STD
1106 1100
1107 _LIBCPP_POP_MACROS 1101 _LIBCPP_POP_MACROS
1108 1102
1109 #endif // _LIBCPP_BITSET 1103 #endif // _LIBCPP_BITSET