Move enum descriptors computation into decltype under C++20. Fixes #58.

This commit is contained in:
Peter Dimov
2025-11-14 13:51:06 +02:00
parent 54b73c7ca7
commit 43ee545507

View File

@@ -43,6 +43,19 @@ template<class... T> auto enum_descriptor_fn_impl( int, T... )
return list<enum_descriptor<T>...>();
}
#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<class... T> auto enum_descriptor_fn_impl( int, T... )
#define BOOST_DESCRIBE_ENUM_END(E) ); }
#endif
} // namespace detail
#if defined(_MSC_VER) && !defined(__clang__)