![]() |
|
|||
File indexing completed on 2025-09-18 08:54:36
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 BOOST_PFR_BEGIN_MODULE_EXPORT 0023 0024 /// 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. 0025 /// Every user may (and in some difficult cases - should) specialize is_reflectable on his own. 0026 /// 0027 /// \b Example: 0028 /// \code 0029 /// namespace boost { namespace pfr { 0030 /// template<class All> struct is_reflectable<A, All> : std::false_type {}; // 'A' won't be interpreted as reflectable everywhere 0031 /// template<> struct is_reflectable<B, boost_fusion_tag> : std::false_type {}; // 'B' won't be interpreted as reflectable in only Boost Fusion 0032 /// }} 0033 /// \endcode 0034 /// \note is_reflectable affects is_implicitly_reflectable, the decision made by is_reflectable is used by is_implicitly_reflectable. 0035 template<class T, class WhatFor> 0036 struct is_reflectable { /* does not have 'value' because value is unknown */ }; 0037 0038 // these specs can't be inherited from 'std::integral_constant< bool, boost::pfr::is_reflectable<T, WhatFor>::value >', 0039 // because it will break the sfinae-friendliness 0040 template<class T, class WhatFor> 0041 struct is_reflectable<const T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {}; 0042 0043 template<class T, class WhatFor> 0044 struct is_reflectable<volatile T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {}; 0045 0046 template<class T, class WhatFor> 0047 struct is_reflectable<const volatile T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {}; 0048 0049 /// Checks the input type for the potential to be reflected. 0050 /// Specialize is_reflectable if you disagree with is_implicitly_reflectable's default decision. 0051 template<class T, class WhatFor> 0052 using is_implicitly_reflectable = std::integral_constant< bool, boost::pfr::detail::possible_reflectable<T, WhatFor>(1L) >; 0053 0054 /// Checks the input type for the potential to be reflected. 0055 /// Specialize is_reflectable if you disagree with is_implicitly_reflectable_v's default decision. 0056 template<class T, class WhatFor> 0057 constexpr bool is_implicitly_reflectable_v = is_implicitly_reflectable<T, WhatFor>::value; 0058 0059 BOOST_PFR_END_MODULE_EXPORT 0060 0061 }} // namespace boost::pfr 0062 0063 #endif // BOOST_PFR_TRAITS_HPP 0064
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |