KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches
Generic Traits

Traits and extension points for any product type. More...

Topics

 kumi::are_uniform_product_types_v
 Checks if a list of product types are homogeneous and of the same underlying type.
 kumi::has_static_size_v
 Detects if a given kumi::container instance size is static.
 kumi::is_comparable_v
 Checks if the expression u == v is well-formed.
 kumi::is_container_v
 Traits detecting types behaving like a kumi::container.
 kumi::is_equality_comparable_v
 Checks if two product types are comparable for equality.
 kumi::is_equivalent_v
 Checks if two product types are equivalent.
 kumi::is_ordered_v
 Checks if the expression a < b is well-formed.
 kumi::is_projection_map_v
 Checks if a type can be used as a kumi::projection_map.
 kumi::is_record_type_v
 Opt-in traits for types behaving like a kumi::record_type.

Classes

struct  kumi::apply_traits< Traits, T, Seq >
 Unpacks a product type and applies its element types as arguments to a meta-function. More...
struct  kumi::common_product_type< Ts >
 Extracts the common product_type of a parameter pack. More...
struct  kumi::map_traits< Traits, T, Seq >
 Applies a unary meta-function to each element of a product type. More...

Typedefs

template<typename T>
using kumi::container_type_t = decltype(kumi_implementation_defined)
 Provides access to the type of the elements of a kumi::concepts::container.
template<std::size_t I, typename T>
using kumi::element_t = std::tuple_element_t<I, std::remove_cvref_t<T>>
 Provides indexed access to the types of the elements of a kumi::product_type.
template<typename Field, typename T>
using kumi::field_of_t = decltype(get<kumi_implementation_defined{}>(kumi::declval<T&&>()))
 The type of the value of T selected by the field Field, resolved by name the same way as kumi::member resolves by index (going through kumi::get).
template<std::size_t I, typename T>
using kumi::member_t = decltype(get<I>(kumi::declval<T&&>()))
 Computes the return type of a call to kumi::get.
template<std::size_t I, typename T>
using kumi::stored_member_t = decltype(kumi_implementation_defined)
 Computes the return type of a call to kumi::get on a kumi::tuple and unwrap the field returned by kumi::get on a kumi::record.

Variables

template<typename... Ts>
constexpr bool kumi::all_unique_names_v = kumi_implementation_defined
 Checks if a parameter pack only contains distinct kumi::field names. Evaluates to false if no type is a kumi::field.
template<typename... Ts>
constexpr bool kumi::all_uniques_v = kumi_implementation_defined
 Checks if a parameter pack only contains distinct types.
template<typename T>
constexpr std::size_t kumi::container_size_v = kumi_implementation_defined
 Returns the statically known number of elements of a kumi::container.
template<typename T, typename U>
constexpr bool kumi::is_instance_of_v = false
 Checks if a type is an instance of a specific template.
template<typename T>
constexpr bool kumi::is_power_type_v = kumi_implementation_defined
 Opt-in traits for types behaving like a kumi::power_type.
template<typename T>
constexpr bool kumi::is_product_type_v = kumi_implementation_defined
 Detects if a type follows the tuple protocol.
template<typename T>
constexpr std::size_t kumi::size_v = std::tuple_size<std::remove_cvref_t<T>>::value
 Computes the number of elements of a kumi::product_type.

Detailed Description

Traits and extension points for any product type.

Typedef Documentation

◆ container_type_t

template<typename T>
using kumi::container_type_t = decltype(kumi_implementation_defined)

Provides access to the type of the elements of a kumi::concepts::container.

Template Parameters
Tkumi::concepts::container to access

Helper type-trait

namespace kumi
{
template<typename T> struct container_type;
}
Main KUMI namespace.
Definition algorithm.hpp:11

◆ element_t

template<std::size_t I, typename T>
using kumi::element_t = std::tuple_element_t<I, std::remove_cvref_t<T>>

Provides indexed access to the types of the elements of a kumi::product_type.

Template Parameters
IIndex of the type to retrieve
Tkumi::product_type to access

Helper type-trait

namespace kumi
{
template<std::size_t I, typename T> struct element;
}

◆ field_of_t

template<typename Field, typename T>
using kumi::field_of_t = decltype(get<kumi_implementation_defined{}>(kumi::declval<T&&>()))

The type of the value of T selected by the field Field, resolved by name the same way as kumi::member resolves by index (going through kumi::get).

Template Parameters
FieldA kumi::field describing the sought identifier
TThe product type to inspect

Helper type-trait

namespace kumi
{
template<typename Field, typename T> struct field_of;
}

◆ member_t

template<std::size_t I, typename T>
using kumi::member_t = decltype(get<I>(kumi::declval<T&&>()))

Computes the return type of a call to kumi::get.

Template Parameters
IIndex of the type to retrieve
Tkumi::product_type to access

Helper type-trait

namespace kumi
{
template<std::size_t I, typename T> struct member;
}

◆ stored_member_t

template<std::size_t I, typename T>
using kumi::stored_member_t = decltype(kumi_implementation_defined)

Computes the return type of a call to kumi::get on a kumi::tuple and unwrap the field returned by kumi::get on a kumi::record.

Template Parameters
IIndex of the type to retrieve
Tkumi::product_type to access

Helper type

namespace kumi
{
template<std::size_t I, typename T> using stored_member_t = typename stored_member<I,T>::type;
}
decltype(kumi_implementation_defined) stored_member_t
Computes the return type of a call to kumi::get on a kumi::tuple and unwrap the field returned by kum...
Definition traits.hpp:480

Variable Documentation

◆ all_unique_names_v

template<typename... Ts>
bool kumi::all_unique_names_v = kumi_implementation_defined
inlineconstexpr

Checks if a parameter pack only contains distinct kumi::field names. Evaluates to false if no type is a kumi::field.

Template Parameters
TsThe types to access

Helper type-trait

namespace kumi
{
template<typename T> struct all_unique_names;
}

◆ all_uniques_v

template<typename... Ts>
bool kumi::all_uniques_v = kumi_implementation_defined
inlineconstexpr

Checks if a parameter pack only contains distinct types.

Template Parameters
TsThe types to access

Helper type-trait

namespace kumi
{
template<typename T> struct all_uniques;
}

◆ container_size_v

template<typename T>
std::size_t kumi::container_size_v = kumi_implementation_defined
inlineconstexpr

Returns the statically known number of elements of a kumi::container.

Template Parameters
Tkumi::container to inspect

Helper type-trait

namespace kumi
{
template<typename T> struct container_size;
}

◆ is_instance_of_v

template<typename T, typename U>
bool kumi::is_instance_of_v = false
inlineconstexpr

Checks if a type is an instance of a specific template.

Template Parameters
TThe type to inspect
Uthe target template

Helper type-trait

namespace kumi
{
template<typename T, typename U> struct is_instance_of;
}

◆ is_power_type_v

template<typename T>
bool kumi::is_power_type_v = kumi_implementation_defined
inlineconstexpr

Opt-in traits for types behaving like a kumi::power_type.

Template Parameters
TType to inspect

To be treated like a power type, an user defined type must support structured bindings as well as exposing a value_type alias.

Helper type-trait

namespace kumi
{
template<typename T> struct is_power_type;
}

Example:

#include <kumi/kumi.hpp>
#include <iostream>
#include <string>
namespace ns
{
template<std::size_t N>
struct span
{
using value_type = int;
using reference = int&;
using const_reference = int const&;
int *p;
};
template<std::size_t I, std::size_t N>
decltype(auto) get(span<N> const& s) noexcept
{
return s.p[I];
}
template<std::size_t I, std::size_t N>
decltype(auto) get(span<N>& s) noexcept
{
return s.p[I];
}
}
// Adapt as structured bindable type
template<std::size_t N>
struct std::tuple_size<ns::span<N>>
: std::integral_constant<std::size_t,N> {};
template<std::size_t I, std::size_t N>
struct std::tuple_element<I,ns::span<N>> { using type = typename ns::span<N>::value_type; };
int main()
{
int array[10] = {1,2,3,4,5,6,7,8,9,10};
ns::span<10> view{array};
kumi::for_each_index( [](auto i, auto e)
{
std::cout << "# " << i
<< " : " << e
<< "\n";
}
,view
);
}
constexpr for_each_index_t for_each_index
Definition for_each.hpp:189
array() -> array< void, 0 >
Deduction guide for the empty power type: kumi::array{} -> kumi::array<> (== array<void,...
decltype(auto) constexpr get(array< T, N > &t) noexcept
Extracts the Ith element from a kumi::array.
Definition array.hpp:672

◆ is_product_type_v

template<typename T>
bool kumi::is_product_type_v = kumi_implementation_defined
inlineconstexpr

Detects if a type follows the tuple protocol.

Template Parameters
TType to inspect

To be treated like a product_type, a user defined type must follow the tuple protocol defined in the standard.

Helper type-trait

namespace kumi
{
template<typename T> struct is_product_type;
}

Example:

#include <kumi/kumi.hpp>
#include <iostream>
#include <string>
namespace ns
{
struct people
{
std::string name;
int age;
};
template<std::size_t I>
decltype(auto) get(people const& s) noexcept
{
if constexpr(I==0) return s.name;
if constexpr(I==1) return s.age;
}
template<std::size_t I>
decltype(auto) get(people& s) noexcept
{
if constexpr(I==0) return s.name;
if constexpr(I==1) return s.age;
}
}
// Adapt as structured bindable type
template<>
struct std::tuple_size<ns::people>
: std::integral_constant<std::size_t,2> {};
template<> struct std::tuple_element<0,ns::people> { using type = std::string; };
template<> struct std::tuple_element<1,ns::people> { using type = int; };
int main()
{
ns::people peter{"Peter Parker", 24};
kumi::for_each_index( [](auto i, auto e)
{
std::cout << "# " << i
<< " : " << e
<< "\n";
}
, peter
);
}
Compile-time text based identifier.
Definition identifier.hpp:165

◆ size_v

template<typename T>
std::size_t kumi::size_v = std::tuple_size<std::remove_cvref_t<T>>::value
inlineconstexpr

Computes the number of elements of a kumi::product_type.

Template Parameters
Tkumi::product_type to inspect

Helper type_trait

namespace kumi
{
template<typename T> struct size;
}