|
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:
accumulate_left() , accumulate_right() , accumulate_associative() - variants of std::accumulate that change the invocation and use of the accumulator object.to_signed() , to_unsigned() - convert integers to their signed or unsigned variants as per std::make_[un]signed.static_abs - statically obtain absolute valuestatic_min , static_max , static_minmax #static_gcd , #static_lcm - statically obtain GCD and LCM of two numbers.static_sum All interfaces are defined in the namespace cxxomfort::library::numeric::.
See also: <numeric> .
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].
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.
1.8.13