4#ifndef TETL_MATH_ABS_HPP
5#define TETL_MATH_ABS_HPP
7#include <etl/_config/all.hpp>
9#include <etl/_concepts/same_as.hpp>
10#include <etl/_type_traits/is_constant_evaluated.hpp>
15inline constexpr struct abs {
17 [[nodiscard]]
constexpr auto operator()(T arg)
const noexcept -> T
26inline constexpr struct fabs {
27 template <
typename Float>
28 [[nodiscard]]
constexpr auto operator()(Float arg)
const noexcept -> Float
31#if __has_builtin(__builtin_fabsf)
32 if constexpr (
etl::same_as<Float,
float>) {
33 return __builtin_fabsf(arg);
36#if __has_builtin(__builtin_fabs)
37 if constexpr (
etl::same_as<Float,
double>) {
38 return __builtin_fabs(arg);
42 return etl::detail::abs(arg);
54 return etl::detail::abs(arg);
59 return etl::detail::abs(arg);
62[[
nodiscard]]
constexpr auto abs(
long long arg)
noexcept ->
long long
64 return etl::detail::abs(arg);
69 return etl::detail::abs(arg);
74 return etl::detail::abs(arg);
77[[
nodiscard]]
constexpr auto abs(
long double arg)
noexcept ->
long double
79 return etl::detail::abs(arg);
Definition adjacent_find.hpp:9
constexpr auto abs(float arg) noexcept -> float
Definition abs.hpp:67
constexpr auto abs(long double arg) noexcept -> long double
Definition abs.hpp:77
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
constexpr auto abs(long arg) noexcept -> long
Definition abs.hpp:57
constexpr auto abs(double arg) noexcept -> double
Definition abs.hpp:72
constexpr auto abs(long long arg) noexcept -> long long
Definition abs.hpp:62
constexpr auto abs(int arg) noexcept -> int
Computes the absolute value of an integer number. The behavior is undefined if the result cannot be r...
Definition abs.hpp:52