Loading [MathJax]/extensions/tex2jax.js
kumi v3.1.0
Exquisite Epidote
 
All Classes Namespaces Functions Variables Friends Modules Pages Concepts
Loading...
Searching...
No Matches

◆ forward_as_tuple()

template<typename... Ts>
KUMI_TRIVIAL_NODISCARD constexpr tuple< Ts &&... > forward_as_tuple ( Ts &&...  ts)
related

Creates a kumi::tuple of forwarding references to its arguments.

Constructs a tuple of references to the arguments in args suitable for forwarding as an argument to a function. The tuple has rvalue reference data members when rvalues are used as arguments, and otherwise has lvalue reference data members.

Note
If the arguments are temporaries, forward_as_tuple does not extend their lifetime; they have to be used before the end of the full expression.
Parameters
tsZero or more lvalue arguments to construct the tuple from.
Returns
A kumi::tuple constructed as kumi::tuple<Ts&&...>(std::forward<Ts>(args)...)

Example:

#include <kumi/tuple.hpp>
#include <iostream>
#include <vector>
#include <string>
template<typename Data>
std::vector<std::string> build(Data d)
{
return std::vector<std::string> ( kumi::get<0>(d)
, std::move(kumi::get<1>(d))
);
}
int main()
{
auto v = build( kumi::forward_as_tuple(4,std::string{"the text !"}));
for(auto const& s : v)
std::cout << s << "\n";
}
constexpr auto from_tuple(tuple< Ts... > const &t)
Converts a kumi::tuple to an instance of an arbitrary type.
Definition convert.hpp:59