Re: (Boost) Reflecto
Emil Dotchevski via Boost <[email protected]>
| Newsgroups | gmane.comp.lib.boost.devel |
|---|---|
| Message-ID | <CAN5fK5Hk93=tt_Fa57b4t4ybf8FhKqea+K4q+bhsdyP3x4EJ2A@mail.gmail.com> |
On Tue, Apr 7, 2026 at 3:12 AM Alexander Grund via Boost < [email protected]> wrote: > Am 06.04.26 um 17:07 schrieb Emil Dotchevski via Boost: > > - 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. > That sounds like a heavy footgun: You can always get the name of an > enumerator / all enumerators , except when you cannot. > For name<->enumerator conversions you could throw/static_assert to > detect this case. > For try-to-name like functions you cannot. > For runtime lookups, the returned name object can be checked to see if the lookup was successful. That's the best behavior possible (it is not undefined behavior). > This is amplified by this being a define > (BOOST_REFLECTO_DEFAULT_ENUM_MIN_VALUE): > When someone (e.g. a consumer of your library built on reflecto) has > already included reflecto and/or defined those then your code will > suddenly break > This is a very good point and it inspired me to find a solution. Now the enum_lookup_range can be specified for all enums within a given namespace, not just for individual enums: namespace lib1 { struct this_namespace; enum class some_enum { .... }; } namespace boost::reflecto { template <> struct enum_lookup_range<specialize_for_namespace<lib1::this_namespace>> { // specialization applies for any enum within the namespace lib1, // including lib1::some_enum. }; } I made this machinery part of the public API in meta_specialization.hpp, so the ability to look up a template specialization based on the namespace of some type is universally available, see https://github.com/zajo/reflecto?tab=readme-ov-file#meta-specialization. _______________________________________________ Boost mailing list -- [email protected] To unsubscribe send an email to [email protected] https://lists.boost.org/mailman3/lists/boost.lists.boost.org/ Archived at: https://lists.boost.org/archives/list/[email protected]/message/2WB76FBAOMXNKJQSOJAQBUCHR3ZQMESF/