File indexing completed on 2025-01-18 09:29:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_CLBL_TRTS_QUALIFIER_FLAGS_HPP
0011 #define BOOST_CLBL_TRTS_QUALIFIER_FLAGS_HPP
0012
0013 #include <boost/callable_traits/detail/config.hpp>
0014
0015 namespace boost { namespace callable_traits { namespace detail {
0016
0017
0018 using qualifier_flags = std::uint32_t;
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 constexpr qualifier_flags default_ = 0;
0043
0044
0045
0046 constexpr qualifier_flags const_ = 1;
0047
0048
0049
0050 constexpr qualifier_flags volatile_ = 2;
0051
0052 #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS
0053
0054 constexpr qualifier_flags lref_ = default_;
0055 constexpr qualifier_flags rref_ = default_;
0056 #else
0057
0058
0059
0060
0061 constexpr qualifier_flags lref_ = 4;
0062
0063
0064
0065
0066 constexpr qualifier_flags rref_ = 8;
0067
0068 #endif
0069
0070 constexpr qualifier_flags cv_ = 3;
0071
0072 template<qualifier_flags Flags>
0073 using remove_const_flag = std::integral_constant<
0074 qualifier_flags, Flags & ~const_>;
0075
0076 template<qualifier_flags Flags>
0077 using is_const = std::integral_constant<bool,
0078 (Flags & const_) != 0>;
0079
0080 template<qualifier_flags Flags>
0081 using remove_volatile_flag = std::integral_constant<
0082 qualifier_flags, Flags & ~volatile_>;
0083
0084 template<typename U, typename T = typename std::remove_reference<U>::type>
0085 using cv_of = std::integral_constant<qualifier_flags,
0086 (std::is_const<T>::value ? const_ : default_)
0087 | (std::is_volatile<T>::value ? volatile_ : default_)>;
0088
0089 template<typename T>
0090 using ref_of = std::integral_constant<qualifier_flags,
0091 std::is_rvalue_reference<T>::value ? rref_
0092 : (std::is_lvalue_reference<T>::value ? lref_
0093 : default_)>;
0094
0095
0096 template<qualifier_flags Existing,
0097 qualifier_flags Other,
0098 bool AlreadyHasRef = (Existing & (lref_ | rref_)) != 0,
0099 bool AlreadyHasLRef = (Existing & lref_) == lref_,
0100 bool IsAddingLRef = (Other & lref_) == lref_
0101 >
0102 using collapse_flags = std::integral_constant<qualifier_flags,
0103 !AlreadyHasRef ? (Existing | Other)
0104 : (AlreadyHasLRef ? (Existing | (Other & ~rref_))
0105 : (IsAddingLRef ? ((Existing & ~rref_) | Other )
0106 : (Existing | Other)))>;
0107
0108 template<typename T> struct flag_map { static constexpr qualifier_flags value = default_; };
0109 template<typename T> struct flag_map<T &> { static constexpr qualifier_flags value = lref_; };
0110 template<typename T> struct flag_map<T &&> { static constexpr qualifier_flags value = rref_; };
0111 template<typename T> struct flag_map<T const> { static constexpr qualifier_flags value = const_; };
0112 template<typename T> struct flag_map<T const &> { static constexpr qualifier_flags value = const_ | lref_; };
0113 template<typename T> struct flag_map<T const &&> { static constexpr qualifier_flags value = const_ | rref_; };
0114 template<typename T> struct flag_map<T volatile> { static constexpr qualifier_flags value = volatile_; };
0115 template<typename T> struct flag_map<T volatile &> { static constexpr qualifier_flags value = volatile_ | lref_; };
0116 template<typename T> struct flag_map<T volatile &&> { static constexpr qualifier_flags value = volatile_ | rref_; };
0117 template<typename T> struct flag_map<T const volatile> { static constexpr qualifier_flags value = const_ | volatile_; };
0118 template<typename T> struct flag_map<T const volatile &> { static constexpr qualifier_flags value = const_ | volatile_ | lref_; };
0119 template<typename T> struct flag_map<T const volatile &&> { static constexpr qualifier_flags value = const_ | volatile_ | rref_; };
0120
0121 }}}
0122
0123 #endif