KFR

Cometa

gcd

template<typename T>
inline constexpr T gcd(T a)

Greatest common divisor

Source:

template <typename T>
constexpr inline T gcd(T a)
{
    return a;
}
template<typename T>
inline constexpr T gcd(T a, T b)

Greatest common divisor

Source:

template <typename T>
constexpr inline T gcd(T a, T b)
{
    return a < b ? gcd(b, a) : ((a % b == 0) ? b : gcd(b, a % b));
}
template<typename T, typename ...Ts>
inline constexpr T gcd(T a, T b, T c, Ts... rest)

Greatest common divisor

Source:

template <typename T, typename... Ts>
constexpr inline T gcd(T a, T b, T c, Ts... rest)
{
    return gcd(a, gcd(b, c, rest...));
}

lcm

template<typename T>
inline constexpr T lcm(T a)

Least common multiple

Source:

template <typename T>
constexpr inline T lcm(T a)
{
    return a;
}
template<typename T>
inline constexpr T lcm(T a, T b)

Least common multiple

Source:

template <typename T>
constexpr inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
template<typename T, typename ...Ts>
inline constexpr T lcm(T a, T b, T c, Ts... rest)

Least common multiple

Source:

template <typename T, typename... Ts>
constexpr inline T lcm(T a, T b, T c, Ts... rest)
{
    return lcm(a, lcm(b, c, rest...));
}

identity

template<typename T>
using identity = typename details::identity_impl<T>::type

Utility typedef used to disable type deduction

Source:

template <typename T>
using identity = typename details::identity_impl<T>::type
using identity = typename details::identity_impl<T>::type

Utility typedef used to disable type deduction

Source:

using identity = typename details::identity_impl<T>::type

swallow

class swallow

Utility class to use in list-initialization context

pass_through

template<typename T>
constexpr T &&pass_through(T &&x) noexcept

Function that returns its first argument

Source:

template <typename T>
CMT_INTRIN constexpr T&& pass_through(T&& x) noexcept
{
    return std::forward<T>(x);
}

noop

template<typename ...Ts>
constexpr void noop(Ts&&...) noexcept

Function that returns void and ignores all its arguments

Source:

template <typename... Ts>
CMT_INTRIN constexpr void noop(Ts&&...) noexcept
{
}

get_first

template<typename T1, typename ...Ts>
constexpr T1 &&get_first(T1 &&x, Ts&&...) noexcept

Function that returns its first argument and ignores all other arguments

Source:

template <typename T1, typename... Ts>
CMT_INTRIN constexpr T1&& get_first(T1&& x, Ts&&...) noexcept
{
    return std::forward<T1>(x);
}

get_second

template<typename T1, typename T2, typename ...Ts>
constexpr T2 &&get_second(T1, T2 &&x, Ts&&...) noexcept

Function that returns its second argument and ignores all other arguments

Source:

template <typename T1, typename T2, typename... Ts>
CMT_INTRIN constexpr T2&& get_second(T1, T2&& x, Ts&&...) noexcept
{
    return std::forward<T2>(x);
}

get_third

template<typename T1, typename T2, typename T3, typename ...Ts>
constexpr T3 &&get_third(T1&&, T2&&, T3 &&x, Ts&&...) noexcept

Function that returns its third argument and ignores all other arguments

Source:

template <typename T1, typename T2, typename T3, typename... Ts>
CMT_INTRIN constexpr T3&& get_third(T1&&, T2&&, T3&& x, Ts&&...) noexcept
{
    return std::forward<T3>(x);
}

returns

template<typename T, typename ...Ts>
constexpr T returns(Ts&&...)

Function that returns value-initialization of type T and ignores all its arguments

Source:

template <typename T, typename... Ts>
CMT_INTRIN constexpr T returns(Ts&&...)
{
    return T();
}

choose_const

template<typename T, typename C1, typename ...Cs>
inline constexpr T choose_const(C1 c1, Cs... constants)

Selects constant of the specific type

CHECK( choose_const<f32>( 32.0f, 64.0 ) == 32.0f );
CHECK( choose_const<f64>( 32.0f, 64.0 ) == 64.0 );

Source:

template <typename T, typename C1, typename... Cs>
constexpr inline T choose_const(C1 c1, Cs... constants)
{
    return std::is_same<T, C1>::value ? static_cast<T>(c1) : choose_const<T>(constants...);
}

array_ref

template<typename T>
class array_ref

Reference to array

type_name

template<typename T>
inline const char *type_name() noexcept

Gets the fully qualified name of the type, including namespace and

template parameters (if any) @tparam T type

Returns:name of the type

Source:

template <typename T>
inline const char* type_name() noexcept
template<typename T>
inline const char *type_name(T x) noexcept

Gets the fully qualified name of the type, including namespace and

template parameters (if any)

Parameters:x – value of specific type
Returns:name of the type

Source:

template <typename T>
inline const char* type_name(T x) noexcept

ctypeid

template<typename T>
inline constexpr type_id_t ctypeid()

Gets unique value associated with the type

@tparam T type

Returns:value of type that supports operator== and operator!=

Source:

template <typename T>
constexpr inline type_id_t ctypeid()
{
    return details::typeident_impl<T>();
}
template<typename T>
inline constexpr type_id_t ctypeid(T x)

Gets unique value associated with the type

Parameters:x – value of specific type
Returns:value of type that supports operator== and operator!=

Source:

template <typename T>
constexpr inline type_id_t ctypeid(T x)
{
    (void)x;
    return details::typeident_impl<T>();
}

function

template<typename Result, typename ...Args>
class function

std::function-like lightweight function wrapper

function<int( float )> f = []( float x ){ return static_cast<int>( x ); };
CHECK( f( 3.4f ) == 3 )

range

template<typename T>
class range

Iterable range

make_range

template<typename T>
range<T> make_range(T begin, T end)

Make iterable range object

Source:

template <typename T>
range<T> make_range(T begin, T end)
template<typename T, typename diff_type = decltype(std::declval<T>() - std::declval<T>())>
range<T> make_range(T begin, T end, diff_type step)

Make iterable range object with step

Source:

template <typename T, typename diff_type = decltype(std::declval<T>() - std::declval<T>())>
range<T> make_range(T begin, T end, diff_type step)

swallow

class swallow

Utility class to use in list-initialization context