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

◆ from_tuple()

template<typename Type , typename... Ts>
requires (!product_type<Type> && _::implicit_constructible<Type, Ts...>)
constexpr auto kumi::from_tuple ( tuple< Ts... > const &  t)
constexpr

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/tuple.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";
}