sm::cem
constexpr maths functions
#include <sm/constexpr_math>
Header file: <sm/constexpr_math>.
Table of Contents
Summary
constexpr
capable basic maths functions that will work in your C++20 and C++23 programs. Eventually, these functions will all be superceded by C++26 functions in the std
namespace.
This file is about 700 lines of cherry-picked code from Keith O’Hara’s GCE Math library (thanks Keith!).
Usage
Use the functions just like their std::
equivalents, but optionally in your constexpr
functions.
The functions provided are:
sm::cem::abs
maps tostd::abs
sm::cem::isinf
maps tostd::isinf
sm::cem::isfinite
maps tostd::isfinite
sm::cem::sqrt
maps tostd::sqrt
sm::cem::pow
maps tostd::pow
sm::cem::exp
maps tostd::exp
sm::cem::log
maps tostd::log
sm::cem::log10
maps tostd::log10
sm::cem::signbit
maps tostd::signbit
sm::cem::sgn
is the signum function (bonus)sm::cem::ceil
maps tostd::ceil
(already constexpr in C++23)sm::cem::floor
maps tostd::floor
(already constexpr in C++23)sm::cem::trunc
maps tostd::trunc
(already constexpr in C++23)sm::cem::round
maps tostd::round
(already constexpr in C++23)sm::cem::sin
maps tostd::sin
sm::cem::cos
maps tostd::cos
sm::cem::tan
maps tostd::tan
sm::cem::asin
maps tostd::asin
sm::cem::acos
maps tostd::acos
sm::cem::atan
maps tostd::atan
sm::cem::atan2
maps tostd::atan2