cxxomfort  rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
Namespaces
cxxomfort::library::numeric Namespace Reference

Supplements to the standard utilities in <numeric>. More...

Namespaces

 ctmath
 Compile-time arithmethic functions, that can be used in template parameters.
 

Functions

template<typename T >
std::make_signed< T >::type to_signed (T t)
 Converts t to the equivalent integral signed type. More...
 
template<typename T >
std::make_unsigned< T >::type to_signed (T t)
 Converts t to the equivalent integral unsigned type. More...
 
template<typename It , typename T , typename F >
accumulate_right (It ini, It fin, T v0, F f)
 Folds a sequence with f from the right . More...
 

Detailed Description

Supplements to the standard utilities in <numeric>.

Function Documentation

◆ to_signed() [1/2]

std::make_signed<T>::type cxxomfort::library::numeric::to_signed ( t)

Converts t to the equivalent integral signed type.

Converts t to the equivalent integral signed type.

Parameters
tA value fo one of C++'s integer types.
Returns
A value of a type similar to t 's, except qualified as signed (eg.: "signed int").

◆ to_signed() [2/2]

std::make_unsigned<T>::type cxxomfort::library::numeric::to_signed ( t)

Converts t to the equivalent integral unsigned type.

Converts t to the equivalent integral unsigned type.

Converts t to the equivalent integral signed type.

Parameters
tA value fo one of C++'s integer types.
Returns
A value of a type similar to t 's, except qualified as signed (eg.: "signed int").

◆ accumulate_right()

T cxxomfort::library::numeric::accumulate_right ( It  ini,
It  fin,
v0,
f 
)

Folds a sequence with f from the right .

Parameters
fAn accumulator object.
v0An initial value.
Returns
The final accumulated value.

This function is exactly like std::accumulate except that the accumulator processes its state value on the right instead of on the left. In other words, if v carries the state, where std::accumulate calculates f(v, x_i), accumulate_right calculates f(x_i, v).