....PFR is a C++14 library for a very basic reflection. It gives you access
to structure elements by index and provides other
std::tuple like
methods for user defined types without macro or boilerplate code:
#include <iostream> #include <string> #include "boost/pfr! std::cout << boost::pfr::io(val); // Outputs: {"Edgar Allan Poe", 1809} }
See limitations.
Imagine that you are writing the wrapper library for a database. Depending on the usage of Boost.PFR users code will look differently:
Otherwise your library could require a customization point for a user type:
With Boost.PFR the code is shorter, more readable and more pleasant to write.
Boost.PFR adds the following out-of-the-box functionality for aggregate initializable structures:
std::tuple
Boost.PFR is a header only library that does not depend on Boost. You can just
copy the content of the "include" folder from
the Boost.PFR github into your project, and the library will work fine.
For a version of the library without
boost:: namespace see PFR.