10#if !__has_cpp_attribute(nodiscard)
11#error "This library requires [[nodiscard]]"
17 concept integral_or_enum = (std::is_integral_v<T> && !std::is_same_v<std::decay_t<T>,
bool>) || std::is_enum_v<T>;
23 constexpr auto to_underlying_type(T
t)
noexcept
25 if constexpr (std::is_enum_v<T>)
26 return static_cast<std::underlying_type_t<T>
>(
t);
31 template <
typename INT_TYPE, auto BIT_NUM>
35 concept valid_flag_bits_v_arguments =
36 std::is_integral_v<RESULT_TYPE> && !std::is_same_v<std::decay_t<RESULT_TYPE>,
bool> &&
37 (integral_or_enum<
decltype(
VALUES)> && ...) &&
38 (detail::allowed_bit_num<RESULT_TYPE, static_cast<decltype(detail::to_underlying_type(VALUES))>(
VALUES)> && ...);
45 template <auto INT_VALUE, auto VALUE>
46 requires detail::valid_flag_bits_v_arguments<
decltype(
INT_VALUE),
VALUE>
50 requires detail::valid_flag_bits_v_arguments<
decltype(
INT_VALUE),
VALUES...>
54 requires detail::valid_flag_bits_v_arguments<
decltype(
INT_VALUE),
VALUES...>
58 requires detail::valid_flag_bits_v_arguments<
decltype(
INT_VALUE),
VALUES...>
62 requires detail::valid_flag_bits_v_arguments<
decltype(
INT_VALUE),
VALUES...>
66 requires detail::valid_flag_bits_v_arguments<
decltype(
INT_VALUE),
VALUES...>
70 requires detail::valid_flag_bits_v_arguments<
decltype(
INT_VALUE),
VALUES...>
71 constexpr inline auto set_flag_to_v =
TO ?
constexpr auto bit_count
Equal to the number of bits in the type.
The below code is based on Sun's libm library code, which is licensed under the following license:
Primary namespace for everything in this library.