7.1. cmath — Common mathematical functions¶
The functions in the cmath module are meant to mimic the ones from
the <cmath> standard library header. The main difference is that they
all live in the subnamespace polder::math::meta and are explicitly meant
to be used at compile time.
Some of the functions in this module are less versatile than their <cmath>
counterparts (e.g. pow) while some of them are more versatile (e.g
min and max). Since the functions are generic, the original names
have been stripped from their type-specific prefixes and suffixes.
7.1.1. Basic functions¶
-
constexpr Number
math::meta::abs(Number x)¶ Return the absolute value of x.
-
constexpr CommonType
math::meta::min(T first, U second, Rest... rest)¶ Return the smallest of two or more arguments. If the arguments have different types, the result type will be the common type of the different arguments,
std::common_type_t<T, U, Rest...>.
-
constexpr CommonType
math::meta::max(T first, U second, Rest... rest)¶ Return the largest of two or more arguments. If the arguments have different types, the result type will be the common type of the different arguments,
std::common_type_t<T, U, Rest...>.
7.1.2. Number-theoretic and representation functions¶
-
constexpr Float
math::meta::floor(Float x)¶ Return the nearest integer not greater than x.
-
constexpr Float
math::meta::ceil(Float x)¶ Return the nearest integer not less than x.
-
constexpr Float
math::meta::round(Float x)¶ Return the nearest integer to x, rounding away from zero in halfway cases.
-
constexpr Float
math::meta::trunc(Float x)¶ Return the nearest integer not greater in magnitude than x.