// Copyright (c) 2022 Denis Mikhailov // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BHO_PFR_TRAITS_HPP #define BHO_PFR_TRAITS_HPP #pragma once #include #include #include /// \file bho/pfr/traits.hpp /// Contains traits \forcedlink{is_reflectable} and \forcedlink{is_implicitly_reflectable} for detecting an ability to reflect type. /// /// \b Synopsis: namespace bho { namespace pfr { /// Has a static const member variable `value` when it is known that type T can or can't be reflected using BHO.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 /// namespace bho { namespace pfr { /// template struct is_reflectable : std::false_type {}; // 'A' won't be interpreted as reflectable everywhere /// 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 is used by is_implicitly_reflectable. template struct is_reflectable { /* does not have 'value' because value is unknown */ }; // these specs can't be inherited from 'std::integral_constant< bool, bho::pfr::is_reflectable::value >', // because it will break the sfinae-friendliness template struct is_reflectable : bho::pfr::is_reflectable {}; template struct is_reflectable : bho::pfr::is_reflectable {}; template struct is_reflectable : bho::pfr::is_reflectable {}; /// Checks the input type for the potential to be reflected. /// Specialize is_reflectable if you disagree with is_implicitly_reflectable's default decision. template using is_implicitly_reflectable = std::integral_constant< bool, bho::pfr::detail::possible_reflectable(1L) >; /// Checks the input type for the potential to be reflected. /// 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; }} // namespace bho::pfr #endif // BHO_PFR_TRAITS_HPP