From 8f503af08aec3e11871e312f3b8ec0a0f3ebd541 Mon Sep 17 00:00:00 2001 From: Julien Blanc Date: Sun, 9 Nov 2025 07:13:57 +0000 Subject: [PATCH 1/3] Fix issue #58 Ensure we don't rely on an unknown return type in the context of incomplete classes definitions Signed-off-by: Julien Blanc --- include/boost/describe/enum.hpp | 2 ++ include/boost/describe/enumerators.hpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/boost/describe/enum.hpp b/include/boost/describe/enum.hpp index dc0f473..cc3fcc3 100644 --- a/include/boost/describe/enum.hpp +++ b/include/boost/describe/enum.hpp @@ -66,6 +66,7 @@ template auto enum_descriptor_fn_impl( int, T... ) #define BOOST_DESCRIBE_NESTED_ENUM(E, ...) \ static_assert(std::is_enum::value, "BOOST_DESCRIBE_NESTED_ENUM should only be used with enums"); \ + friend bool boost_has_nested_enum_descriptor_fn( E** ) { return true; } \ friend BOOST_DESCRIBE_ENUM_BEGIN(E) \ BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_ENUM_ENTRY, E, __VA_ARGS__) \ BOOST_DESCRIBE_ENUM_END(E) @@ -81,6 +82,7 @@ template auto enum_descriptor_fn_impl( int, T... ) #define BOOST_DESCRIBE_NESTED_ENUM(E, ...) \ static_assert(std::is_enum::value, "BOOST_DESCRIBE_NESTED_ENUM should only be used with enums"); \ + friend bool boost_has_nested_enum_descriptor_fn( E** ) { return true; } \ BOOST_DESCRIBE_MAYBE_UNUSED friend BOOST_DESCRIBE_ENUM_BEGIN(E) \ BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_ENUM_ENTRY, E, ##__VA_ARGS__) \ BOOST_DESCRIBE_ENUM_END(E) diff --git a/include/boost/describe/enumerators.hpp b/include/boost/describe/enumerators.hpp index f50c470..1a0afd1 100644 --- a/include/boost/describe/enumerators.hpp +++ b/include/boost/describe/enumerators.hpp @@ -20,6 +20,7 @@ namespace describe // describe_enumerators template using describe_enumerators = decltype( boost_enum_descriptor_fn( static_cast(0) ) ); +template using nested_describe_enumerators = decltype (boost_has_nested_enum_descriptor_fn(static_cast(0) ) ); // has_describe_enumerators @@ -34,6 +35,10 @@ template struct has_describe_enumerators struct has_describe_enumerators>>: std::true_type +{ +}; + } // namespace detail template using has_describe_enumerators = detail::has_describe_enumerators; From 9cdd1276f09e88fbea1a9b501211d147a7b2cc62 Mon Sep 17 00:00:00 2001 From: Julien Blanc Date: Sun, 9 Nov 2025 07:18:46 +0000 Subject: [PATCH 2/3] Adds a test for #58 Signed-off-by: Julien Blanc --- test/nested_enum_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/nested_enum_test.cpp b/test/nested_enum_test.cpp index 0ef5ecf..54a1600 100644 --- a/test/nested_enum_test.cpp +++ b/test/nested_enum_test.cpp @@ -27,6 +27,10 @@ class X2 BOOST_DESCRIBE_NESTED_ENUM(E, v1, v2) +#if defined(BOOST_DESCRIBE_CXX14) + static_assert(boost::describe::has_describe_enumerators::value, ""); +#endif + public: typedef E E2; From 6e631fdb24499e4c38b157a3453ba9ebe709ae8a Mon Sep 17 00:00:00 2001 From: Julien Blanc Date: Wed, 12 Nov 2025 10:58:41 +0000 Subject: [PATCH 3/3] Fix compilation for old msvc --- include/boost/describe/enumerators.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/boost/describe/enumerators.hpp b/include/boost/describe/enumerators.hpp index 1a0afd1..e0fab3d 100644 --- a/include/boost/describe/enumerators.hpp +++ b/include/boost/describe/enumerators.hpp @@ -35,13 +35,21 @@ template struct has_describe_enumerators struct has_describe_enumerators>>: std::true_type +template struct has_nested_describe_enumerators: std::false_type { }; +template struct has_nested_describe_enumerators>>: std::true_type +{ +}; + +template struct has_describe_enumerators_or_nested_describe_enumerators : std::integral_constant::value || has_describe_enumerators::value> +{ +}; } // namespace detail -template using has_describe_enumerators = detail::has_describe_enumerators; +template using has_describe_enumerators = detail::has_describe_enumerators_or_nested_describe_enumerators; } // namespace describe } // namespace boost