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

◆ forward_as_record()

template<concepts::identifier auto... Fields, typename... Ts>
auto forward_as_record ( Ts &&... ts) -> record< field< decltype(Fields), Ts && >... >
related

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

Constructs a record of references to the arguments in args suitable for forwarding as an argument to a function. The record 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_record does not extend their lifetime; they have to be used before the end of the full expression.
Template Parameters
FieldsNon type template parameters names to associate to the each element.
Parameters
tsZero or more lvalue arguments to construct the record from.
Returns
A kumi::record constructed as kumi::record<Ts&&...>(std::forward<Ts>(args)...)

Example:

#include <kumi/kumi.hpp>
#include <iostream>
#include <vector>
#include <string>
using namespace kumi::literals;
template<typename Data>
std::vector<std::string> build(Data d)
{
return std::vector<std::string> ( kumi::get<"a"_id>(d)
, std::move(kumi::get<"b"_id>(d))
);
}
int main()
{
auto v = build( kumi::forward_as_record<"a"_id, "b"_id>(4,std::string{"the text !"}));
for(auto const& s : v)
std::cout << s << "\n";
}
constexpr auto forward_as_record(Ts &&... ts) -> record< field< decltype(Fields), Ts && >... >
Creates a kumi::record of forwarding references to its arguments.
Definition record.hpp:378
constexpr decltype(auto) get(record< Ts... > &&r) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition record.hpp:506