From e460ce2ddcd4721b2920c9b58bee25d82d0f7108 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Mon, 27 Feb 2023 10:59:34 +0300 Subject: [PATCH] Always define is_implicitly_reflectable (#124) Always define is_implicitly_reflectable --- doc/pfr.qbk | 2 +- .../boost/pfr/detail/possible_reflectable.hpp | 12 ++++++++++++ include/boost/pfr/traits.hpp | 16 ++++++---------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/doc/pfr.qbk b/doc/pfr.qbk index d371e58..6a25c57 100644 --- a/doc/pfr.qbk +++ b/doc/pfr.qbk @@ -1,6 +1,6 @@ [library Boost.PFR [quickbook 1.6] - [version 2.0] + [version 2.1] [copyright 2016-2023 Antony Polukhin] [category Language Features Emulation] [license diff --git a/include/boost/pfr/detail/possible_reflectable.hpp b/include/boost/pfr/detail/possible_reflectable.hpp index 069fafd..a47c2ce 100644 --- a/include/boost/pfr/detail/possible_reflectable.hpp +++ b/include/boost/pfr/detail/possible_reflectable.hpp @@ -20,6 +20,8 @@ constexpr decltype(is_reflectable::value) possible_reflectable(long) return is_reflectable::value; } +#if BOOST_PFR_ENABLE_IMPLICIT_REFLECTION + template constexpr bool possible_reflectable(int) noexcept { # if defined(__cpp_lib_is_aggregate) @@ -30,6 +32,16 @@ constexpr bool possible_reflectable(int) noexcept { # endif } +#else + +template +constexpr bool possible_reflectable(int) noexcept { + // negative answer here won't change behaviour in PFR-dependent libraries(like Fusion) + return false; +} + +#endif + }}} // namespace boost::pfr::detail #endif // BOOST_PFR_DETAIL_POSSIBLE_REFLECTABLE_HPP diff --git a/include/boost/pfr/traits.hpp b/include/boost/pfr/traits.hpp index 79d8f43..c490339 100644 --- a/include/boost/pfr/traits.hpp +++ b/include/boost/pfr/traits.hpp @@ -19,8 +19,8 @@ namespace boost { namespace pfr { -/// Has a static const member variable `value` when it known that type T can or can't be reflected using Boost.PFR; otherwise, there is no member variable. -/// Every user may(and in some difficult cases - should) specialize is_reflectable on his own. +/// Has a static const member variable `value` when it is known that type T can or can't be reflected using Boost.PFR; otherwise, there is no member variable. +/// Every user may (and in some difficult cases - should) specialize is_reflectable on his own. /// /// \b Example: /// \code @@ -29,11 +29,9 @@ namespace boost { namespace pfr { /// template<> struct is_reflectable : std::false_type {}; // 'B' won't be interpreted as reflectable in only Boost Fusion /// }} /// \endcode -/// \note is_reflectable affects is_implicitly_reflectable, the decision made by is_reflectable has more priority than is_implicitly_reflectable, -/// because is_reflectable is more sharp than is_implicitly_reflectable -/// +/// \note is_reflectable affects is_implicitly_reflectable, the decision made by is_reflectable is used by is_implicitly_reflectable. template -struct is_reflectable { /* do not has 'value' because value is unknown */ }; +struct is_reflectable { /* does not have 'value' because value is unknown */ }; // these specs can't be inherited from 'std::integral_constant< bool, boost::pfr::is_reflectable::value >', // because it will break the sfinae-friendliness @@ -46,17 +44,15 @@ struct is_reflectable : boost::pfr::is_reflectable struct is_reflectable : boost::pfr::is_reflectable {}; -#if BOOST_PFR_ENABLE_IMPLICIT_REFLECTION /// Checks the input type for the potential to be reflected. -/// Specialize is_reflectable if you are disagree with is_implicitly_reflectable's default decision. +/// Specialize is_reflectable if you disagree with is_implicitly_reflectable's default decision. template using is_implicitly_reflectable = std::integral_constant< bool, boost::pfr::detail::possible_reflectable(1L) >; /// Checks the input type for the potential to be reflected. -/// Specialize is_reflectable if you are disagree with is_implicitly_reflectable_v's default decision. +/// Specialize is_reflectable if you disagree with is_implicitly_reflectable_v's default decision. template constexpr bool is_implicitly_reflectable_v = is_implicitly_reflectable::value; -#endif }} // namespace boost::pfr