cxxomfort  rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/

cxxomfort Supplementals for <numeric>

This component provides supplementary features for the set of algorithms present in <numeric> that are specific to cxxomfort, in particular pre-C++11 compile-time versions of the utilities like gcd() and lcm() that were made constexpr.

Interfaces defined here:

All interfaces are defined in the namespace cxxomfort::library::numeric::.

See also: <numeric> .

Numerics

The cxxomfort supplemental templates static_min , static_max and static_minmax provide constant-time evaluation of the minimum and maximum of a set of integers as Non-Type Template Parameters, in particular useful for C++<11 where constexpr and its application on std::[min|max] are not available.

static_min and static_max return their results via the ::value member. static_minmax returns the members ::min_value and max_value.

Pre-C++11, these templates take a type and up to 5 (five) numeric parameters.

The supplemental static_sum takes a type and up to 10 (ten) template parameters and returns as the member ::value the sum (addition) of those values.

The supplementals static_gcd and static_lcm provide the same kind of compatible functionality to the C++17 constexpr implementations of std::[gcd,lcm].

Conversions

The cxxomfort supplementals to_signed() and to_unsigned() convert a numeric expression to the corresponding signed or unsigned variant of the type. They are intended as functional supplements to type_traits' make_[signed,unsigned].

Neither function performs range checking.