Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stl/inc/__msvc_bit_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ _CONSTEXPR20 decltype(auto) _Select_popcount_impl(_Fn _Callback) {

#undef _HAS_POPCNT_INTRINSICS
#undef _HAS_TZCNT_BSF_INTRINSICS
#undef _POPCNT_INTRINSICS_ALWAYS_AVAILABLE

_STD_END

Expand Down
7 changes: 7 additions & 0 deletions stl/inc/bit
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ _NODISCARD constexpr int countl_zero(_Ty _Val) noexcept;

_EXPORT_STD template <_Standard_unsigned_integral _Ty>
_NODISCARD constexpr bool has_single_bit(const _Ty _Val) noexcept {
#if defined(_POPCNT_INTRINSICS_ALWAYS_AVAILABLE) && _POPCNT_INTRINSICS_ALWAYS_AVAILABLE
if (_STD is_constant_evaluated()) {
return (_Val ^ (_Val - 1)) > _Val - 1;
}
return _Unchecked_popcount(_Val) == 1;
#else
return (_Val ^ (_Val - 1)) > _Val - 1;
#endif // ! _POPCNT_INTRINSICS_ALWAYS_AVAILABLE
}

inline void _Precondition_violation_in_bit_ceil() noexcept {}
Expand Down