...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_with_name
// In header: <boost/pfr/core_name.hpp> template<typename T, typename F> constexpr void for_each_field_with_name(T && value, F && func);
Calls func
for each field with its name of a value
Example:
struct Toto { int a; char c; }; Toto t {5, 'c'}; auto print = [](std::string_view name, const auto& value){ std::cout << "Name: " << name << " Value: " << value << std::endl; }; for_each_field_with_name(t, print);
Parameters: |
|