mirror of
https://github.com/boostorg/describe.git
synced 2026-01-19 04:12:07 +00:00
Move enum descriptors computation into decltype under C++20. Fixes #58.
This commit is contained in:
@@ -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__)
|
||||
|
||||
Reference in New Issue
Block a user