diff --git a/include/boost/describe/enum.hpp b/include/boost/describe/enum.hpp index dc0f473..ff09878 100644 --- a/include/boost/describe/enum.hpp +++ b/include/boost/describe/enum.hpp @@ -43,6 +43,19 @@ template auto enum_descriptor_fn_impl( int, T... ) return list...>(); } +#if __cplusplus >= 202002L || ( defined(_MSVC_LANG) && _MSVC_LANG >= 202002L ) + +#define BOOST_DESCRIBE_ENUM_BEGIN(E) \ + inline decltype( boost::describe::detail::enum_descriptor_fn_impl( 0 + +#define BOOST_DESCRIBE_ENUM_ENTRY(E, e) , []{ struct _boost_desc { \ + static constexpr auto value() noexcept { return E::e; } \ + static constexpr auto name() noexcept { return #e; } }; return _boost_desc(); }() + +#define BOOST_DESCRIBE_ENUM_END(E) ) ) boost_enum_descriptor_fn( E** ) { return {}; } + +#else + #define BOOST_DESCRIBE_ENUM_BEGIN(E) \ inline auto boost_enum_descriptor_fn( E** ) \ { return boost::describe::detail::enum_descriptor_fn_impl( 0 @@ -53,6 +66,8 @@ template auto enum_descriptor_fn_impl( int, T... ) #define BOOST_DESCRIBE_ENUM_END(E) ); } +#endif + } // namespace detail #if defined(_MSC_VER) && !defined(__clang__)