Skip to content

v0.5.0

Latest

Choose a tag to compare

@Yaraslaut Yaraslaut released this 01 Oct 18:07
7c6dd27

Highlights

  • Aggregates with members that have no default constructor can be reflected. CountMembers reported such types as having no members, and MemberTypeOf required the aggregate to be default-constructible, so none of the APIs built on them worked. (#29, #30)
  • Empty aggregates are accepted by CallOnMembers, FoldMembers and Inspect. (#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 ToTuple use 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)
  • Inspect compiles for any member type: enums are shown by value, optionals by their value or nullopt, ranges as [a, b], and anything that cannot be formatted by its type name. (#30)
  • No accidental copies. FoldMembers moves the accumulator instead of copying it, which also makes move-only accumulators usable. (#30)
  • TypeNameOf no longer truncates array types such as int[3], and on MSVC no longer turns unsigned int into int. (#30)
  • A type whose members cannot be counted fails with a readable static_assert instead 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

  • FoldMembers passes the accumulator to the callable as an rvalue. A callable taking it as a non-const lvalue reference no longer compiles.
  • CallOnMembersWithoutName passes the plain member type as template argument, where it passed a reference type before.
  • Inspect prints enum members by their numeric value.
  • MaxReflectionMemerCount is renamed to MaxReflectionMemberCount. 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

New Contributors

Full Changelog: v0.4.0...v0.5.0