diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
commit | 31773f157bf8164364649b5f470f52dece0a4317 (patch) | |
tree | 33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /contrib/libs/cxxsupp/libcxx/include/__bit_reference | |
parent | 2c7938962d8689e175574fc1e817c05049f27905 (diff) | |
parent | eff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff) | |
download | ydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz |
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__bit_reference')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__bit_reference | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit_reference b/contrib/libs/cxxsupp/libcxx/include/__bit_reference index 107368759c..9032b8f018 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit_reference +++ b/contrib/libs/cxxsupp/libcxx/include/__bit_reference @@ -171,45 +171,6 @@ private: __bit_const_reference& operator=(const __bit_const_reference&) = delete; }; -// count - -template <bool _ToCount, class _Cp, bool _IsConst> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __bit_iterator<_Cp, _IsConst>::difference_type -__count_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) { - using _It = __bit_iterator<_Cp, _IsConst>; - using __storage_type = typename _It::__storage_type; - using difference_type = typename _It::difference_type; - - const int __bits_per_word = _It::__bits_per_word; - difference_type __r = 0; - // do first partial word - if (__first.__ctz_ != 0) { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = std::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __r = std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m); - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_)); - // do last partial word - if (__n > 0) { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m); - } - return __r; -} - -template <class _Cp, bool _IsConst, class _Tp> -inline _LIBCPP_HIDE_FROM_ABI typename __bit_iterator<_Cp, _IsConst>::difference_type -count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value) { - if (static_cast<bool>(__value)) - return std::__count_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first)); - return std::__count_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first)); -} - // fill_n template <bool _FillValue, class _Cp> @@ -1092,7 +1053,7 @@ private: _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC> __find_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); template <bool _ToCount, class _Dp, bool _IC> - friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 + friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); }; |