1 /* 2 Copyright Barrett Adair 2016-2017 3 4 Distributed under the Boost Software License, Version 1.0. 5 (See accompanying file LICENSE.md or copy at http ://boost.org/LICENSE_1_0.txt) 6 7 */ 8 9 #ifndef BOOST_CLBL_TRTS_DETAIL_DEFAULT_BOOST_CLBL_TRTS_HPP 10 #define BOOST_CLBL_TRTS_DETAIL_DEFAULT_BOOST_CLBL_TRTS_HPP 11 12 namespace boost { namespace callable_traits { namespace detail { 13 14 template<typename T = void> 15 struct default_callable_traits { 16 17 // value is used by all traits classes to participate 18 // in the <callable_traits/detail/traits.hpp> disjunction. 19 static constexpr bool value = false; 20 21 // used facilitate the disjunction in 22 // <callable_traits/detail/traits.hpp> 23 using traits = default_callable_traits; 24 25 using error_t = error_type<T>; 26 27 // represents the type under consideration 28 using type = error_t; 29 30 // std::true_type for callables with C-style variadics 31 using has_varargs = std::false_type; 32 33 using return_type = error_t; 34 35 // arg_types is a std::tuple of argument types for 36 // callables that are not overloaded/templated function objects. 37 // arg_types IS defined in terms of INVOKE, which means 38 // a PMF's arg_types tuple will use a reference to its 39 // parent class as the first argument, with qualifiers added to 40 // match the PMF's own qualifiers. 41 using arg_types = error_t; 42 43 // arg_types without the decltype(*this) parameter for member functions 44 using non_invoke_arg_types = error_t; 45 46 // An "approximation" of a callable type, in the form 47 // of a plain function type. Defined in terms of INVOKE. 48 // An identity alias for qualified/unqualified plain function 49 // types. 50 using function_type = error_t; 51 52 // Used to smoothen the edges between PMFs and function objects 53 using function_object_signature = error_t; 54 55 // An identity alias for qualified/unqualified plain function 56 // types. Equivalent to remove_member_pointer for PMFs. Same 57 // as function_type for other callable types. 58 using qualified_function_type = error_t; 59 60 // Removes C-style variadics from a signature, if present. 61 // Aliases error_t for function objects and PMDs. 62 using remove_varargs = error_t; 63 64 // Adds C-style variadics to a signature. Aliases 65 // error_t for function objects and PMDs. 66 using add_varargs = error_t; 67 68 // std::true_type when the signature includes noexcept, when 69 // the feature is available 70 using is_noexcept = std::false_type; 71 72 // adds noexcept to a signature if the feature is available 73 using add_noexcept = error_t; 74 75 // removes noexcept from a signature if present 76 using remove_noexcept = error_t; 77 78 // std::true_type when the signature includes transaction_safe, when 79 // the feature is available 80 using is_transaction_safe = std::false_type; 81 82 // adds transaction_safe to a signature if the feature is available 83 using add_transaction_safe = error_t; 84 85 // removes transaction_safe from a signature if present 86 using remove_transaction_safe = error_t; 87 88 // The class of a PMD or PMF. error_t for other types 89 using class_type = error_t; 90 91 // The qualified reference type of class_type. error_t 92 // for non-member-pointers. 93 using invoke_type = error_t; 94 95 // Removes reference qualifiers from a signature. 96 using remove_reference = error_t; 97 98 // Adds an lvalue qualifier to a signature, in arbitrary 99 // accordance with C++11 reference collapsing rules. 100 using add_member_lvalue_reference = error_t; 101 102 // Adds an rvalue qualifier to a signature, in arbitrary 103 // accordance with C++11 reference collapsing rules. 104 using add_member_rvalue_reference = error_t; 105 106 // Adds a const qualifier to a signature. 107 using add_member_const = error_t; 108 109 // Adds a volatile qualifier to a signature. 110 using add_member_volatile = error_t; 111 112 // Adds both const and volatile qualifiers to a signature. 113 using add_member_cv = error_t; 114 115 // Removes a const qualifier from a signature, if present. 116 using remove_member_const = error_t; 117 118 // Removes a volatile qualifier from a signature, if present. 119 using remove_member_volatile = error_t; 120 121 // Removes both const and volatile qualifiers from a 122 // signature, if any. 123 using remove_member_cv = error_t; 124 125 // Removes the member pointer from PMDs and PMFs. An identity 126 // alias for other callable types. 127 using remove_member_pointer = error_t; 128 129 // Changes the parent class type for PMDs and PMFs. Turns 130 // function pointers, function references, and 131 // qualified/unqualified function types into PMFs. Turns 132 // everything else into member data pointers. 133 template<typename C, 134 typename U = T, 135 typename K = typename std::remove_reference<U>::type, 136 typename L = typename std::conditional< 137 std::is_same<void, K>::value, error_t, K>::type, 138 typename Class = typename std::conditional< 139 std::is_class<C>::value, C, error_t>::type> 140 using apply_member_pointer = typename std::conditional< 141 std::is_same<L, error_t>::value || std::is_same<Class, error_t>::value, 142 error_t, L Class::*>::type; 143 144 // Changes the return type of PMFs, function pointers, function 145 // references, and qualified/unqualified function types. Changes 146 // the data type of PMDs. error_t for function objects. 147 template<typename> 148 using apply_return = error_t; 149 150 // Expands the argument types into a template 151 template<template<class...> class Container> 152 using expand_args = error_t; 153 154 template<template<class...> class Container, typename... RightArgs> 155 using expand_args_left = error_t; 156 157 template<template<class...> class Container, typename... LeftArgs> 158 using expand_args_right = error_t; 159 160 using clear_args = error_t; 161 162 template<typename... NewArgs> 163 using push_front = error_t; 164 165 template<typename... NewArgs> 166 using push_back = error_t; 167 168 template<std::size_t ElementCount> 169 using pop_front = error_t; 170 171 template<std::size_t ElementCount> 172 using pop_back = error_t; 173 174 template<std::size_t Index, typename... NewArgs> 175 using insert_args = error_t; 176 177 template<std::size_t Index, std::size_t Count> 178 using remove_args = error_t; 179 180 template<std::size_t Index, typename... NewArgs> 181 using replace_args = error_t; 182 183 static constexpr qualifier_flags cv_flags = cv_of<T>::value; 184 static constexpr qualifier_flags ref_flags = ref_of<T>::value; 185 static constexpr qualifier_flags q_flags = cv_flags | ref_flags; 186 187 using has_member_qualifiers = std::integral_constant<bool, q_flags != default_>; 188 using is_const_member = std::integral_constant<bool, 0 < (cv_flags & const_)>; 189 using is_volatile_member = std::integral_constant<bool, 0 < (cv_flags & volatile_)>; 190 using is_cv_member = std::integral_constant<bool, cv_flags == (const_ | volatile_)>; 191 192 #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS 193 using is_reference_member = std::false_type; 194 using is_lvalue_reference_member = std::false_type; 195 using is_rvalue_reference_member = std::false_type; 196 #else 197 using is_reference_member = std::integral_constant<bool, 0 < ref_flags>; 198 using is_lvalue_reference_member = std::integral_constant<bool, ref_flags == lref_>; 199 using is_rvalue_reference_member = std::integral_constant<bool, ref_flags == rref_>; 200 #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS 201 202 }; 203 204 }}} // namespace boost::callable_traits::detail 205 206 #endif // BOOST_CLBL_TRTS_DETAIL_DEFAULT_BOOST_CLBL_TRTS_HPP 207 208