File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -867,7 +867,16 @@ bitset<_Size>::to_string(char __zero, char __one) const {
867867
868868template <size_t _Size>
869869inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT {
870- return static_cast <size_t >(std::count (__base::__make_iter (0 ), __base::__make_iter (_Size), true ));
870+ # if defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
871+ if constexpr (_Size == 0 ) {
872+ return 0 ;
873+ } else if constexpr (_Size <= __base::__bits_per_word) {
874+ return __builtin_popcountg (static_cast <unsigned _BitInt (_Size)>(__base::__first_));
875+ } else
876+ # endif
877+ {
878+ return static_cast <size_t >(std::count (__base::__make_iter (0 ), __base::__make_iter (_Size), true ));
879+ }
871880}
872881
873882template <size_t _Size>
You can’t perform that action at this time.
0 commit comments