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

◆ from_tuple()

template<typename Type, typename... Ts>
requires (!concepts::product_type<Type> && kumi_implementation_defined)
auto kumi::from_tuple ( tuple< Ts... > const & t)
inlinenodiscardconstexpr

Converts a kumi::tuple to an instance of an arbitrary type.

Constructs an instance of Type by passing elements of t to the appropriate constructor.

Template Parameters
TypeType to generate
Parameters
tkumi::tuple to convert
Returns
An instance of Type constructed from each element of t in order.

Example

#include <kumi/kumi.hpp>
#include <iostream>
#include <string>
struct my_struct
{
int i;
float f;
std::string name;
};
int main()
{
auto a = kumi::make_tuple(1337, 2.3475f, "John");
auto b = from_tuple<my_struct>( a );
std::cout << a << "\n";
std::cout << b.i << ' ' << b.f << ' ' << b.name << "\n";
}
Compile-time text based identifier.
Definition identifier.hpp:162