4#ifndef TETL_CMATH_POW_HPP
5#define TETL_CMATH_POW_HPP
7#include <etl/_config/all.hpp>
9#include <etl/_3rd_party/gcem/gcem.hpp>
10#include <etl/_type_traits/is_constant_evaluated.hpp>
16inline constexpr struct pow {
17 template <
typename Float>
18 [[nodiscard]]
constexpr auto operator()(Float base, Float exponent)
const noexcept -> Float
21#if __has_constexpr_builtin(__builtin_powf)
22 if constexpr (etl::same_as<Float,
float>) {
23 return __builtin_powf(base, exponent);
26#if __has_constexpr_builtin(__builtin_pow)
27 if constexpr (etl::same_as<Float,
double>) {
28 return __builtin_pow(base, exponent);
32#if __has_builtin(__builtin_powf)
33 if constexpr (etl::same_as<Float,
float>) {
34 return __builtin_powf(base, exponent);
37#if __has_builtin(__builtin_pow)
38 if constexpr (etl::same_as<Float,
double>) {
39 return __builtin_pow(base, exponent);
44 return etl::detail::gcem::pow(base, exponent);
57 return etl::detail::pow(base, exp);
64 return etl::detail::pow(base, exp);
71 return etl::detail::pow(base, exp);
76[[
nodiscard]]
constexpr auto pow(
long double base,
long double exp) ->
long double
78 return etl::detail::pow(base, exp);
83[[
nodiscard]]
constexpr auto powl(
long double base,
long double exp) ->
long double
85 return etl::detail::pow(base, exp);
92 return etl::detail::pow(base,
static_cast<
float>(iexp));
99 return etl::detail::pow(base,
static_cast<
double>(iexp));
104[[
nodiscard]]
constexpr auto pow(
long double base,
int iexp) ->
long double
106 return etl::detail::pow(base,
static_cast<
long double>(iexp));
constexpr auto pow(long double base, int iexp) -> long double
Computes the value of base raised to the power exp.
Definition pow.hpp:104
constexpr auto powl(long double base, long double exp) -> long double
Computes the value of base raised to the power exp.
Definition pow.hpp:83
constexpr auto pow(float base, int iexp) -> float
Computes the value of base raised to the power exp.
Definition pow.hpp:90
constexpr auto pow(long double base, long double exp) -> long double
Computes the value of base raised to the power exp.
Definition pow.hpp:76
constexpr auto pow(double base, int iexp) -> double
Computes the value of base raised to the power exp.
Definition pow.hpp:97
constexpr auto pow(float base, float exp) -> float
Definition pow.hpp:55
constexpr auto pow(double base, double exp) -> double
Computes the value of base raised to the power exp.
Definition pow.hpp:69
constexpr auto powf(float base, float exp) -> float
Computes the value of base raised to the power exp.
Definition pow.hpp:62
Definition adjacent_find.hpp:9
constexpr auto is_constant_evaluated() noexcept -> bool
Detects whether the function call occurs within a constant-evaluated context. Returns true if the eva...
Definition is_constant_evaluated.hpp:17