Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Function template tie_from_structure

pfr::tie_from_structure — std::tie-like function that allows assigning to tied values from aggregates.

Synopsis

// In header: <pfr/core.hpp>


template<typename... Elements> 
  unspecified tie_from_structure(Elements &... args);

Description

Example:

auto f() {
  struct { struct { int x, y } p; short s; } res { { 4, 5 }, 6 };
  return res;
}
auto [p, s] = f();
pfr::tie_from_structure(p, s) = f();

Returns:

an object with lvalue references to args...; on assignment of an simple aggregate value to that object each field of an aggregate is assigned to the corresponding args... reference.


PrevUpHomeNext