kumi v3.1.0
Exquisite Epidote
 
Loading...
Searching...
No Matches

◆ type_cast()

template<typename... Ts, product_type T>
requires ( sizeof...(Ts) == size_v<T> )
constexpr auto kumi::type_cast ( T &&  t)
inlineconstexpr

Converts a product_type<Types...> to an instance of a product_type<Ts...>

Template Parameters
Tsdestination types to of each member of the product type
Parameters
tProduct type to convert
Returns
A Product type containing the values of t where each member type is the corresponding type in the input pack.

Helper type

namespace kumi::result
{
template<typename... Ts, product_type T> struct type_cast;
template<typename... Ts, product_type T>
using type_cast_t = typename type_cast<Ts..., T>::type;
}
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:33
constexpr auto type_cast(T &&t)
Converts a product_type<Types...> to an instance of a product_type<Ts...>
Definition cast.hpp:44

Computes the return type of a call to kumi::type_cast

Example

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
kumi::tuple a = { 14.f, 42, '7', short{89} };
auto b = kumi::type_cast<int, bool, float, char>(a);
std::cout << a << "\n";
std::cout << b << "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:37