Skip to content

CoMeta

array_ref

array_ref class

template <typename T> array_ref

Reference to array

Source code
template <typename T>
struct array_ref
{
public:
    using value_type             = T;
    using pointer                = value_type*;
    using const_pointer          = const value_type*;
    using reference              = value_type&;
    using const_reference        = const value_type&;
    using iterator               = pointer;
    using const_iterator         = const_pointer;
    using reverse_iterator       = std::reverse_iterator<pointer>;
    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
    using size_type              = std::size_t;
    using difference_type        = std::ptrdiff_t;

    constexpr array_ref() CMT_NOEXCEPT : m_data(nullptr), m_size(0) {}
    constexpr array_ref(const array_ref&) CMT_NOEXCEPT            = default;
    constexpr array_ref(array_ref&&) CMT_NOEXCEPT                 = default;
    constexpr array_ref& operator=(const array_ref&) CMT_NOEXCEPT = default;
    constexpr array_ref& operator=(array_ref&&) CMT_NOEXCEPT      = default;

    template <typename Container, CMT_HAS_DATA_SIZE(Container)>
    array_ref(Container&& cont) : array_ref(std::data(cont), std::size(cont))
    {
    }

    constexpr array_ref(std::initializer_list<T> vec) CMT_NOEXCEPT : m_data(vec.begin()), m_size(vec.size())
    {
    }
    constexpr array_ref(T* data, size_type size) CMT_NOEXCEPT : m_data(data), m_size(size) {}

    constexpr reference front() const CMT_NOEXCEPT { return m_data[0]; }
    constexpr reference back() const CMT_NOEXCEPT { return m_data[m_size - 1]; }
    constexpr iterator begin() const CMT_NOEXCEPT { return m_data; }
    constexpr iterator end() const CMT_NOEXCEPT { return m_data + m_size; }
    constexpr const_iterator cbegin() const CMT_NOEXCEPT { return m_data; }
    constexpr const_iterator cend() const CMT_NOEXCEPT { return m_data + m_size; }
    constexpr pointer data() const CMT_NOEXCEPT { return m_data; }
    constexpr std::size_t size() const CMT_NOEXCEPT { return m_size; }
    constexpr bool empty() const CMT_NOEXCEPT { return !m_size; }
    constexpr reference operator[](std::size_t index) const { return m_data[index]; }

private:
    pointer m_data;
    size_type m_size;
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/array.hpp#L19

b8 typedef

b8 = bool

Short names for common types

Source code
using b8   = bool

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/numeric.hpp#L12

choose_const function

template <typename T, typename C1, typename... Cs,
          CMT_ENABLE_IF(std::is_same_v<T, C1>)>
constexpr T choose_const(C1 c1, Cs...)

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 code
template <typename T, typename C1, typename... Cs, CMT_ENABLE_IF(std::is_same_v<T, C1>)>
constexpr CMT_INTRINSIC T choose_const(C1 c1, Cs...)
{
    return static_cast<T>(c1);
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1731

ctypeid function

template <typename T> constexpr inline type_id_t ctypeid()

Gets unique value associated with the type @tparam T type @return value of type that supports operator== and operator!=

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

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/ctti.hpp#L106

template <typename T>
constexpr inline type_id_t ctypeid(T x)

Gets unique value associated with the type
x value of specific type @return value of type that supports operator== and operator!=

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

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/ctti.hpp#L116

datatype

datatype enum

enum class datatype : int

An enumeration representing data type

Source code
enum class datatype : int
{
    typebits_mask  = 0xFF,
    f              = 0x100, // floating point
    i              = 0x200, // signed integer
    u              = 0x300, // unsigned integer
    c              = 0x400, // complex floating point
    b              = 0x500, // boolean
    typeclass_mask = 0xF00,
    f16            = static_cast<int>(f) | 16,
    f32            = static_cast<int>(f) | 32,
    f64            = static_cast<int>(f) | 64,
    f80            = static_cast<int>(f) | 80,
    i8             = static_cast<int>(i) | 8,
    i16            = static_cast<int>(i) | 16,
    i24            = static_cast<int>(i) | 24,
    i32            = static_cast<int>(i) | 32,
    i64            = static_cast<int>(i) | 64,
    u8             = static_cast<int>(u) | 8,
    u16            = static_cast<int>(u) | 16,
    u24            = static_cast<int>(u) | 24,
    u32            = static_cast<int>(u) | 32,
    u64            = static_cast<int>(u) | 64,
    c32            = static_cast<int>(c) | 32,
    c64            = static_cast<int>(c) | 64,
    b8             = static_cast<int>(b) | 8
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/numeric.hpp#L86

function

function class

template <typename F> function

std::function-like lightweight function wrapper

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

Source code
template <typename F>
struct function

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/function.hpp#L53

gcd function

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

Greatest common divisor

Source code
template <typename T>
constexpr CMT_INTRINSIC T gcd(T a)
{
    return a;
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L942

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

Greatest common divisor

Source code
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));
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L949

template <typename T, typename... Ts>
constexpr T gcd(T a, T b, T c, Ts... rest)

Greatest common divisor

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

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L956

get_first function

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

Function that returns its first argument and ignores all other arguments

Source code
template <typename T1, typename... Ts>
CMT_INTRINSIC constexpr T1&& get_first(T1&& x, Ts&&...) CMT_NOEXCEPT
{
    return std::forward<T1>(x);
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1307

get_second function

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

Function that returns its second argument and ignores all other arguments

Source code
template <typename T1, typename T2, typename... Ts>
CMT_INTRINSIC constexpr T2&& get_second(T1, T2&& x, Ts&&...) CMT_NOEXCEPT
{
    return std::forward<T2>(x);
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1314

get_third function

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

Function that returns its third argument and ignores all other arguments

Source code
template <typename T1, typename T2, typename T3, typename... Ts>
CMT_INTRINSIC constexpr T3&& get_third(T1&&, T2&&, T3&& x, Ts&&...) CMT_NOEXCEPT
{
    return std::forward<T3>(x);
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1321

identity typedef

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

Utility typedef used to disable type deduction

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

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1143

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

Utility typedef used to disable type deduction

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

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1143

is_numeric variable

template <typename T>
constexpr inline bool is_numeric =
    is_number<deep_subtype<T>>

Check if the type argument is a number or a vector of numbers

Source code
template <typename T>
constexpr inline bool is_numeric = is_number<deep_subtype<T>>

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1110

is_numeric_args variable

template <typename... Ts>
constexpr inline bool is_numeric_args = (is_numeric<Ts> &&
                                         ...)

Check if the type arguments are a numbers or a vectors of numbers

Source code
template <typename... Ts>
constexpr inline bool is_numeric_args = (is_numeric<Ts> && ...)

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1114

is_numeric_or_bool variable

template <typename T>
constexpr inline bool is_numeric_or_bool =
    is_number_or_bool<deep_subtype<T>>

Check if the type argument is a number, bool or a vector of numbers of bool

Source code
template <typename T>
constexpr inline bool is_numeric_or_bool = is_number_or_bool<deep_subtype<T>>

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1118

lcm function

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

Least common multiple

Source code
template <typename T>
constexpr CMT_INTRINSIC T lcm(T a)
{
    return a;
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L963

template <typename T> constexpr T lcm(T a, T b)

Least common multiple

Source code
template <typename T>
constexpr CMT_INTRINSIC T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L970

template <typename T, typename... Ts>
constexpr T lcm(T a, T b, T c, Ts... rest)

Least common multiple

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

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L977

make_range function

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

Make iterable range object

Source code
template <typename T>
constexpr range<T> make_range(T begin, T end)
{
    return range<T>(begin, end, end > begin ? 1 : -1);
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/range.hpp#L61

template <typename T, typename D>
constexpr range<std::common_type_t<T, D>>
make_range(T begin, T end, D step)

Make iterable range object with step

Source code
template <typename T, typename D>
constexpr range<std::common_type_t<T, D>> make_range(T begin, T end, D step)
{
    return range<std::common_type_t<T, D>>(begin, end, step);
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/range.hpp#L68

next_poweroftwo function

template <typename T> constexpr T next_poweroftwo(T n)

Returns a nearest power of two that is greater or equal than n

Source code
template <typename T>
constexpr CMT_INTRINSIC T next_poweroftwo(T n)
{
    return n > 2 ? T(1) << (ilog2(n - 1) + 1) : n;
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L922

noop function

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

Function that returns void and ignores all its arguments

Source code
template <typename... Ts>
CMT_INTRINSIC constexpr void noop(Ts&&...) CMT_NOEXCEPT
{
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1301

pass_through function

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

Function that returns its first argument

Source code
template <typename T>
CMT_INTRINSIC constexpr T&& pass_through(T&& x) CMT_NOEXCEPT
{
    return std::forward<T>(x);
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1294

prev_poweroftwo function

template <typename T> constexpr T prev_poweroftwo(T n)

Returns a nearest power of two that is less or equal than n

Source code
template <typename T>
constexpr CMT_INTRINSIC T prev_poweroftwo(T n)
{
    return n > 2 ? T(1) << (ilog2(n)) : n;
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L929

range

range class

template <typename T> range

Iterable range

Source code
template <typename T>
struct range
{
    using value_type      = T;
    using reference       = T&;
    using const_reference = const T&;
    using pointer         = T*;
    using const_pointer   = const T*;
    using diff_type       = decltype(std::declval<T>() - std::declval<T>());

    constexpr range(value_type begin, value_type end, diff_type step) CMT_NOEXCEPT : min(begin),
                                                                                     max(end),
                                                                                     step(step)
    {
    }

    struct iterator
    {
        value_type value;
        diff_type step;
        constexpr const_reference operator*() const { return value; }
        constexpr const_pointer operator->() const { return &value; }
        constexpr iterator& operator++()
        {
            value += step;
            return *this;
        }
        constexpr iterator operator++(int)
        {
            iterator copy = *this;
            ++(*this);
            return copy;
        }
        constexpr bool operator!=(const iterator& other) const
        {
            return step > 0 ? value < other.value : value > other.value;
        }
    };
    value_type min;
    value_type max;
    diff_type step;
    constexpr iterator begin() const { return iterator{ min, step }; }
    constexpr iterator end() const { return iterator{ max, step }; }

    constexpr T distance() const { return max - min; }
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/range.hpp#L13

return_constant function

template <typename T, T value, typename... Args>
constexpr T return_constant(Args &&...)

Function that returns constant of type T and ignores all its arguments

Source code
template <typename T, T value, typename... Args>
CMT_INTRINSIC constexpr T return_constant(Args&&...)
{
    return value;
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1335

returns function

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

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

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

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1328

swallow

swallow class

swallow

Utility class to use in list-initialization context

Source code
struct swallow
{
    template <typename... T>
    CMT_MEM_INTRINSIC constexpr swallow(T&&...) CMT_NOEXCEPT
    {
    }
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa.hpp#L1146

swallow

swallow

Utility class to use in list-initialization context

Source code
struct swallow

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/tuple.hpp#L23

type_name function

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

Gets the fully qualified name of the type, including namespace and template parameters (if any) @tparam T type @return name of the type

Source code
template <typename T>
inline const char* type_name() CMT_NOEXCEPT
{
    static const auto name = ctype_name<T>();
    return name.c_str();
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/ctti.hpp#L81

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

Gets the fully qualified name of the type, including namespace and template parameters (if any)
x value of specific type @return name of the type

Source code
template <typename T>
inline const char* type_name(T x) CMT_NOEXCEPT
{
    (void)x;
    return type_name<T>();
}

https://github.com/kfrlib/kfr/blob//include/kfr/cometa/ctti.hpp#L94


Auto-generated from sources, Revision , https://github.com/kfrlib/kfr/blob//include/kfr/