4#ifndef TETL_MATH_IPOW_HPP
5#define TETL_MATH_IPOW_HPP
7#include <etl/_concepts/builtin_integer.hpp>
8#include <etl/_type_traits/make_unsigned.hpp>
12template <builtin_integer Int>
13[[nodiscard]]
constexpr auto ipow(Int base, Int exponent)
noexcept -> Int
16 for (
auto i = Int(0); i < exponent; ++i) {
22template <
unsigned long long Base, builtin_integer Int>
23[[nodiscard]]
constexpr auto ipow(Int exponent)
noexcept -> Int
25 using UInt =
etl::make_unsigned_t<Int>;
27 if constexpr (Base == 2ULL) {
28 return static_cast<Int>(UInt(1) << UInt(exponent));
29 }
else if constexpr (Base == 4ULL) {
30 return static_cast<Int>(UInt(1) << UInt(exponent * Int(2)));
31 }
else if constexpr (Base == 8ULL) {
32 return static_cast<Int>(UInt(1) << UInt(exponent * Int(3)));
33 }
else if constexpr (Base == 16ULL) {
34 return static_cast<Int>(UInt(1) << UInt(exponent * Int(4)));
35 }
else if constexpr (Base == 32ULL) {
36 return static_cast<Int>(UInt(1) << UInt(exponent * Int(5)));
38 return etl::ipow(
static_cast<Int>(Base), exponent);
Definition adjacent_find.hpp:9
constexpr auto ipow(Int base, Int exponent) noexcept -> Int
Definition ipow.hpp:13
constexpr auto ipow(Int exponent) noexcept -> Int
Definition ipow.hpp:23