...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Caution | |
---|---|
Recommended C++ Standards are C++17 and above. Library requires at least C++14! Pre C++14 compilers (C++11, C++03...) are not supported. |
Boost.PFR library works with types that satisfy the requirements of SimpleAggregate
: aggregate types without
base classes, const
fields, references,
or C arrays:
struct simple_aggregate { // SimpleAggregate std::string name; int age; boost::uuids::uuid uuid; }; struct empty { // SimpleAggregate }; struct aggregate : empty { // not a SimpleAggregate std::string name; int age; boost::uuids::uuid uuid; };
The library may work with aggregates that don't satisfy the requirements of
SimpleAggregate
, but the behavior
tends to be non-portable.
By default Boost.PFR auto-detects your compiler abilities and automatically defines the configuration macro into appropriate values. If you wish to override that behavior, just define:
Table 28.2. Macros
Macro name |
Effect |
---|---|
BOOST_PFR_USE_CPP17 |
Define to |
BOOST_PFR_USE_LOOPHOLE |
Define to |
BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE |
Define to |
The Boost.PFRs reflection has some limitations that depend on a C++ Standard and compiler capabilities:
boost::pfr::get
,
boost::pfr::structure_to_tuple
,
boost::pfr::structure_tie
,
boost::pfr::tuple_element
require T to be a POD type with built-in types only.