A C++14 library providing std::tuple-like reflection for user-defined aggregate types without macros or boilerplate.
Boost.PFR (Precise and Flat Reflection) is a C++14 library that provides basic compile-time reflection for aggregate data types. It enables developers to treat plain structs like tuples—accessing fields by index, getting the field count, and serializing to streams—without writing macros or repetitive boilerplate code.
C++ developers working with aggregate types (structs/classes) who need reflection for serialization, logging, debugging, or interoperability with tuple-based APIs, especially in projects avoiding heavy code-generation tools.
It offers a lightweight, header-only solution for reflection that integrates seamlessly with standard C++ and other Boost libraries, eliminating macro clutter while maintaining high performance through compile-time introspection.
std::tuple like methods for user defined types without any macro or boilerplate code
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables access to struct fields by index using `boost::pfr::get<N>(obj)` without any macros or boilerplate code, as shown in the motivating examples where structs are used like tuples.
Integrates seamlessly with other Boost libraries like Boost.Spirit through Fusion adaptation, allowing for easy parsing and serialization, demonstrated in Example #3 with ast_employee.
Can be used as a standalone header-only library by copying the 'include' folder, with no dependencies on the full Boost distribution, making it easy to integrate into projects.
Provides `tuple_size`, `tuple_element_t`, and structured binding support for user-defined aggregates, mirroring standard tuple functionality for generic algorithms.
Only works with aggregate types, excluding classes with private members, non-default constructors, or inheritance, which restricts its use in object-oriented designs as noted in the requirements.
Reflection is performed at compile-time, so it cannot handle dynamic types or provide runtime introspection, limiting flexibility for scenarios requiring type erasure or reflection on unknown types.
Relies on C++14 and advanced metaprogramming, which may cause issues with older or less compliant compilers, and the header-only nature can lead to longer compile times in large projects.