Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 4 additions & 6 deletions include/bits/bits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ constexpr FirstType xorOp(FirstType first, SecondType second) noexcept {
* @return `true` if the specified bits are set in the source value.
*/
template <std::unsigned_integral T>
constexpr T bitsAreSet(T sourceBits, T bitMaskToCheck) {
constexpr bool bitsAreSet(T sourceBits, T bitMaskToCheck) {
return andOp(sourceBits, bitMaskToCheck) != 0;
}

Expand All @@ -452,17 +452,15 @@ constexpr T bitsAreSet(T sourceBits, T bitMaskToCheck) {
* @return `true` if the specified bits are set in the source value.
*/
template <std::integral SourceBitsType, std::integral BitMaskType>
constexpr SourceBitsType bitsAreSet(SourceBitsType sourceBits, BitMaskType bitMaskToCheck) {
constexpr bool bitsAreSet(SourceBitsType sourceBits, BitMaskType bitMaskToCheck) {
using MaxType = Max<SourceBitsType, BitMaskType>;

if constexpr (std::is_signed_v<SourceBitsType> || std::is_signed_v<BitMaskType>) {
using MaxUnsignedType = std::make_unsigned_t<MaxType>;

return static_cast<SourceBitsType>(
bitsAreSet(static_cast<MaxUnsignedType>(sourceBits), static_cast<MaxUnsignedType>(bitMaskToCheck)));
return bitsAreSet(static_cast<MaxUnsignedType>(sourceBits), static_cast<MaxUnsignedType>(bitMaskToCheck));
} else {
return static_cast<SourceBitsType>(
bitsAreSet(static_cast<MaxType>(sourceBits), static_cast<MaxType>(bitMaskToCheck)));
return bitsAreSet(static_cast<MaxType>(sourceBits), static_cast<MaxType>(bitMaskToCheck));
}
}

Expand Down
Loading