...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::pfr::for_each_field
// In header: <boost/pfr/core.hpp> template<typename T, typename F> void for_each_field(T && value, F && func);
Calls func
for each field of a value
.
Example:
struct my_struct { int i, short s; }; int sum = 0; boost::pfr::for_each_field(my_struct{20, 22}, [&sum](const auto& field) { sum += field; }); assert(sum == 42);
Parameters: |
|