I wrote a small constexpr type/enum reflection library which I think may be a good addition to Boost. It needs C++17, although it relies on implementation-specific support (works on gcc, clang and msvc). https://github.com/zajo/reflecto
сб, 4 апр. 2026 г. в 21:48, Emil Dotchevski via Boost <boost@lists.boost.org>:
I wrote a small constexpr type/enum reflection library which I think may be a good addition to Boost. It needs C++17, although it relies on implementation-specific support (works on gcc, clang and msvc).
The type name reflection functionality already exists in Boost in TypeIndex library https://www.boost.org/doc/libs/1_91_0_beta1/doc/html/doxygen/boost_typeindex... : ``` static_assert( boost::typeindex::ctti_type_index:::type_id<int>().name() == std::string_view{"int"} ); ``` -- Best regards, Antony Polukhin
Hi Emil, If you expand this library (which I suppose is based upon the ideas in magic-enum), I would suggest adding the functionality in "light enum" available at https://github.com/gloinart/light_enum (note, made by me). Light enum has the same features as magic enum, with the difference that the enums are "registered" in .cpp files before usage. This way, the compile time overhead of magic enum is avoided. As a bonus, you can also introspect an enum even if you only have a forward declaration available. Best /Viktor On Sun, Apr 5, 2026 at 1:48 AM Emil Dotchevski via Boost < boost@lists.boost.org> wrote:
I wrote a small constexpr type/enum reflection library which I think may be a good addition to Boost. It needs C++17, although it relies on implementation-specific support (works on gcc, clang and msvc).
https://github.com/zajo/reflecto _______________________________________________ Boost mailing list -- boost@lists.boost.org To unsubscribe send an email to boost-leave@lists.boost.org https://lists.boost.org/mailman3/lists/boost.lists.boost.org/ Archived at: https://lists.boost.org/archives/list/boost@lists.boost.org/message/NLGU2ADV...
On Sun, Apr 5, 2026 at 10:36 AM Viktor Sehr via Boost <boost@lists.boost.org> wrote:
Hi Emil, If you expand this library (which I suppose is based upon the ideas in magic-enum), I would suggest adding the functionality in "light enum" available at https://github.com/gloinart/light_enum (note, made by me). Light enum has the same features as magic enum, with the difference that the enums are "registered" in .cpp files before usage. This way, the compile time overhead of magic enum is avoided.
Boost.Describe already does that and a ton more.
On 4 Apr 2026 21:47, Emil Dotchevski via Boost wrote:
I wrote a small constexpr type/enum reflection library which I think may be a good addition to Boost. It needs C++17, although it relies on implementation-specific support (works on gcc, clang and msvc).
Why are the enum_lookup_range limits necessary? As far as I could tell from my brief glance at the code, you simply cut the enum value names from function signature strings, no actual lookup is involved, so why the limits? Also, since the library only deals with producing name strings for types and enum values, I think Reflecto is a bit ambitious name. I would expect more advanced features from a reflection library, e.g. the ability to iterate over enum values or struct data members.
On Mon, Apr 6, 2026 at 6:42 AM Andrey Semashev via Boost < boost@lists.boost.org> wrote:
On 4 Apr 2026 21:47, Emil Dotchevski via Boost wrote:
I wrote a small constexpr type/enum reflection library which I think may be a good addition to Boost. It needs C++17, although it relies on implementation-specific support (works on gcc, clang and msvc).
Why are the enum_lookup_range limits necessary? As far as I could tell from my brief glance at the code, you simply cut the enum value names from function signature strings, no actual lookup is involved, so why the limits?
- enum_value_name() can be invoked with a variable at run-time. This is implemented in terms of indexing a constexpr array constructed over the lookup range at compile time. If the value is out of the lookup range, that's indicated in the state of the returned name object. - enum_value_names<E> returns a constexpr array of name/value pairs (like Describe does for described enums) that includes only the named values; there is also named_enum_value_count and min_/max_named_enum_value.
participants (5)
-
Andrey Semashev -
Antony Polukhin -
Emil Dotchevski -
Viktor Sehr -
Vinnie Falco