7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MATH_POWER_OF_2_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MATH_POWER_OF_2_HPP_
18#include "arene/base/stdlib_choice/climits.hpp"
19#include "arene/base/stdlib_choice/cstddef.hpp"
20#include "arene/base/stdlib_choice/cstdint.hpp"
21#include "arene/base/stdlib_choice/enable_if.hpp"
22#include "arene/base/stdlib_choice/integer_sequence.hpp"
23#include "arene/base/stdlib_choice/is_integral.hpp"
24#include "arene/base/stdlib_choice/make_unsigned.hpp"
34template <typename Integer, constraints<std::enable_if_t<std::is_integral<Integer>::value>> =
nullptr>
39 constexpr Integer zero{
static_cast<Integer
>(0)};
40 constexpr unsigned_integer unsigned_zero{0U};
44 return (value > zero) && (
static_cast<unsigned_integer
>(
45 static_cast<unsigned_integer
>(value) & (
static_cast<unsigned_integer
>(value) - 1U)
62namespace power_of_2_detail {
83template <std::
size_t Begin, std::
size_t End, constra
ints<std::enable_if_t<(End >= Begin)>> =
nullptr>
85 return power_of_2_detail::make_power_of_2_sequence(
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Definition accumulate.hpp:37
constexpr auto is_power_of_2(Integer value) noexcept -> bool
Check if an integer is a positive power-of-two.
Definition power_of_2.hpp:35
constexpr auto power_of_2(std::uint64_t const value) noexcept -> std::uint64_t
Raises 2 to the power of a value.
Definition power_of_2.hpp:54
constexpr auto make_power_of_2_sequence() noexcept
Return the sequence of 2^N for each N in the half-open range [Begin,End)
Definition power_of_2.hpp:84
Definition accumulate.hpp:36
make_integer_sequence< size_t, Size > make_index_sequence
A helper alias template for make_integer_sequence<size_t, Size>
Definition integer_sequence.hpp:224
integer_sequence< size_t, Ints... > index_sequence
A helper alias template for integer_sequence<size_t, Ints>
Definition integer_sequence.hpp:218
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
::uint64_t uint64_t
A 64-bit unsigned integer type.
Definition cstdint.hpp:47
typename make_unsigned< Type >::type make_unsigned_t
A type alias for the equivalent unsigned type for integral and enumeration types other than bool.
Definition make_unsigned.hpp:252