KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches

Creates a kumi::array of forwarding references to its arguments. More...

Variables

constexpr forward_as_array_t kumi::forward_as_array {}

Detailed Description

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

Variable Documentation

◆ forward_as_array

forward_as_array_t kumi::forward_as_array {}
inlineconstexprnodiscard

Constructs an array of references to the arguments in ts 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_array does not extend their lifetime; they have to be used before the end of the full expression.

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<typename... Ts>
constexpr auto forward_as_array(Ts&&... ts);
}
constexpr forward_as_array_t forward_as_array
Definition array.hpp:397
Main KUMI namespace.
Definition algorithm.hpp:11

Parameters

  • ts: Zero or more arguments to construct the array from.

Return value

Example

#include <kumi/kumi.hpp>
#include <iostream>
template<typename Data>
int sum(Data d)
{
return kumi::get<0>(d) + kumi::get<1>(d) + kumi::get<2>(d);
}
int main()
{
int a = 1;
int b = 2;
int c = 3;
// forward_as_array builds an array of references, here an array<int&, 3>.
auto arr = kumi::forward_as_array(a, b, c);
std::cout << sum(arr) << "\n";
}
constexpr sum_t sum
Definition reduce.hpp:376
decltype(auto) constexpr get(array< T, N > &t) noexcept
Extracts the Ith element from a kumi::array.
Definition array.hpp:672