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

◆ from_tuple()

template<typename Type, typename... Ts>
auto from_tuple ( tuple< Ts... > const & t)
related

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";
}
constexpr auto from_tuple(tuple< Ts... > const &t)
Converts a kumi::tuple to an instance of an arbitrary type.
Definition tuple.hpp:516
constexpr auto make_tuple(Ts &&... ts) -> tuple< std::unwrap_ref_decay_t< Ts >... >
Creates a tuple object, deducing the target type from the types of arguments.
Definition tuple.hpp:467
Compile-time text based ID.
Definition identifier.hpp:147