Repository navigation
Highlights
- Aggregates with members that have no default constructor can be reflected.
CountMembersreported such types as having no members, andMemberTypeOfrequired the aggregate to be default-constructible, so none of the APIs built on them worked. (#29, #30) - Empty aggregates are accepted by
CallOnMembers,FoldMembersandInspect. (#30) - Types in anonymous namespaces and at function scope are supported with GCC and Clang. MSVC still requires external linkage for member names. (#31)
- Faster compilation. Where the compiler provides structured binding packs (Clang 21 and later, GCC 16 in C++26 mode), member counting and
ToTupleuse them and no longer cost compile time proportional to the number of members. Other compilers count members by binary search instead of a linear recursion, which is several times faster for large aggregates. (#29, #30) Inspectcompiles for any member type: enums are shown by value, optionals by their value ornullopt, ranges as[a, b], and anything that cannot be formatted by its type name. (#30)- No accidental copies.
FoldMembersmoves the accumulator instead of copying it, which also makes move-only accumulators usable. (#30) TypeNameOfno longer truncates array types such asint[3], and on MSVC no longer turnsunsigned intintoint. (#30)- A type whose members cannot be counted fails with a readable
static_assertinstead of exceeding the template instantiation depth. (#29) - The public API is documented in the README and in the header. (#31)
Changes that may require adjustments
FoldMemberspasses the accumulator to the callable as an rvalue. A callable taking it as a non-const lvalue reference no longer compiles.CallOnMembersWithoutNamepasses the plain member type as template argument, where it passed a reference type before.Inspectprints enum members by their numeric value.MaxReflectionMemerCountis renamed toMaxReflectionMemberCount. The old name remains as a deprecated alias. (#28, thanks @data-man)
Compiler support
The library is now built and tested with GCC 13–16, Clang 17–22, Apple Clang, MSVC and clang-cl, in C++20, C++23 and, where supported, C++26.
Full Changelog: v0.4.0...v0.5.0
What's Changed
- Support members without a default constructor in CountMembers by @Yaraslaut in #29
- Fix reflection of non-default-constructible and empty aggregates by @Yaraslaut in #30
- Fix typo by @data-man in #28
- Prepare release 0.5.0 by @Yaraslaut in #31
New Contributors
Full Changelog: v0.4.0...v0.5.0