Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Function template tie_from_structure

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

Synopsis

// In header: <boost/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();
boost::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