1// Copyright (c) 2022 Denis Mikhailov
2//
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef BOOST_PFR_TRAITS_HPP
7#define BOOST_PFR_TRAITS_HPP
8#pragma once
9
10#include <boost/pfr/detail/config.hpp>
11
12#include <boost/pfr/detail/possible_reflectable.hpp>
13#include <type_traits>
14
15/// \file boost/pfr/traits.hpp
16/// Contains traits \forcedlink{is_reflectable} and \forcedlink{is_implicitly_reflectable} for detecting an ability to reflect type.
17///
18/// \b Synopsis:
19
20namespace boost { namespace pfr {
21
22/// 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.
23/// Every user may (and in some difficult cases - should) specialize is_reflectable on his own.
24///
25/// \b Example:
26/// \code
27/// namespace boost { namespace pfr {
28/// template<class All> struct is_reflectable<A, All> : std::false_type {}; // 'A' won't be interpreted as reflectable everywhere
29/// template<> struct is_reflectable<B, boost_fusion_tag> : std::false_type {}; // 'B' won't be interpreted as reflectable in only Boost Fusion
30/// }}
31/// \endcode
32/// \note is_reflectable affects is_implicitly_reflectable, the decision made by is_reflectable is used by is_implicitly_reflectable.
33template<class T, class WhatFor>
34struct is_reflectable { /* does not have 'value' because value is unknown */ };
35
36// these specs can't be inherited from 'std::integral_constant< bool, boost::pfr::is_reflectable<T, WhatFor>::value >',
37// because it will break the sfinae-friendliness
38template<class T, class WhatFor>
39struct is_reflectable<const T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {};
40
41template<class T, class WhatFor>
42struct is_reflectable<volatile T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {};
43
44template<class T, class WhatFor>
45struct is_reflectable<const volatile T, WhatFor> : boost::pfr::is_reflectable<T, WhatFor> {};
46
47/// Checks the input type for the potential to be reflected.
48/// Specialize is_reflectable if you disagree with is_implicitly_reflectable's default decision.
49template<class T, class WhatFor>
50using is_implicitly_reflectable = std::integral_constant< bool, boost::pfr::detail::possible_reflectable<T, WhatFor>(1L) >;
51
52/// Checks the input type for the potential to be reflected.
53/// Specialize is_reflectable if you disagree with is_implicitly_reflectable_v's default decision.
54template<class T, class WhatFor>
55constexpr bool is_implicitly_reflectable_v = is_implicitly_reflectable<T, WhatFor>::value;
56
57}} // namespace boost::pfr
58
59#endif // BOOST_PFR_TRAITS_HPP
60
61

source code of boost/libs/pfr/include/boost/pfr/traits.hpp