Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:43:38

0001 // Copyright (c) 2022 Denis Mikhailov
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_PFR_TRAITS_HPP
0007 #define BOOST_PFR_TRAITS_HPP
0008 #pragma once
0009 
0010 #include <boost/pfr/detail/config.hpp>
0011 
0012 #include <boost/pfr/detail/possible_reflectable.hpp>
0013 #include <type_traits>
0014 
0015 /// \file boost/pfr/traits.hpp
0016 /// Contains traits \forcedlink{is_reflectable} and \forcedlink{is_implicitly_reflectable} for detecting an ability to reflect type.
0017 ///
0018 /// \b Synopsis:
0019 
0020 namespace boost { namespace pfr {
0021 
0022 /// 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.
0023 /// Every user may (and in some difficult cases - should) specialize is_reflectable on his own.
0024 ///
0025 /// \b Example:
0026 /// \code
0027 ///     namespace boost { namespace pfr {
0028 ///         template<class All> struct is_reflectable<A, All> : std::false_type {};       // 'A' won't be interpreted as reflectable everywhere
0029 ///         template<> struct is_reflectable<B, boost_fusion_tag> : std::false_type {};   // 'B' won't be interpreted as reflectable in only Boost Fusion
0030 ///     }}
0031 /// \endcode
0032 /// \note is_reflectable affects is_implicitly_reflectable, the decision made by is_reflectable is used by is_implicitly_reflectable.
0033 template<class T, class WhatFor>
0034 struct is_reflectable { /*  does not have 'value' because value is unknown */ };
0035 
0036 // these specs can't be inherited from 'std::integral_constant< bool, boost::pfr::is_reflectable<T, WhatFor>::value >',
0037 // because it will break the sfinae-friendliness
0038 template<class T, class WhatFor>
0039 struct is_reflectable<const T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {};
0040 
0041 template<class T, class WhatFor>
0042 struct is_reflectable<volatile T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {};
0043 
0044 template<class T, class WhatFor>
0045 struct is_reflectable<const volatile T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {};
0046 
0047 /// Checks the input type for the potential to be reflected.
0048 /// Specialize is_reflectable if you disagree with is_implicitly_reflectable's default decision.
0049 template<class T, class WhatFor>
0050 using is_implicitly_reflectable = std::integral_constant< bool, boost::pfr::detail::possible_reflectable<T, WhatFor>(1L) >;
0051 
0052 /// Checks the input type for the potential to be reflected.
0053 /// Specialize is_reflectable if you disagree with is_implicitly_reflectable_v's default decision.
0054 template<class T, class WhatFor>
0055 constexpr bool is_implicitly_reflectable_v = is_implicitly_reflectable<T, WhatFor>::value;
0056 
0057 }} // namespace boost::pfr
0058 
0059 #endif // BOOST_PFR_TRAITS_HPP
0060