1 #ifndef BOOST_CLBL_TRTS_PARAMETER_INDEX_HELPER_HPP 2 #define BOOST_CLBL_TRTS_PARAMETER_INDEX_HELPER_HPP 3 4 #include <boost/callable_traits/detail/config.hpp> 5 6 namespace boost { namespace callable_traits { namespace detail { 7 8 template<std::size_t I, typename T, bool IgnoreThisPointer = false, 9 bool AllowPlus1 = false, std::size_t Count = 0> 10 struct parameter_index_helper { 11 12 using error_t = error_type<T>; 13 14 using args_tuple = typename std::conditional<IgnoreThisPointer, 15 typename detail::traits<T>::non_invoke_arg_types, 16 typename detail::traits<T>::arg_types>::type; 17 18 static constexpr bool has_parameter_list = 19 !std::is_same<args_tuple, invalid_type>::value 20 && !std::is_same<args_tuple, reference_error>::value; 21 22 using temp_tuple = typename std::conditional<has_parameter_list, 23 args_tuple, std::tuple<error_t>>::type; 24 25 static constexpr std::size_t parameter_list_size = 26 std::tuple_size<temp_tuple>::value; 27 28 static constexpr bool is_out_of_range = has_parameter_list && 29 I >= parameter_list_size + static_cast<std::size_t>(AllowPlus1); 30 31 static constexpr bool is_count_out_of_range = has_parameter_list && 32 I + Count > parameter_list_size + static_cast<std::size_t>(AllowPlus1); 33 34 static constexpr std::size_t index = 35 has_parameter_list && !is_out_of_range ? I : 0; 36 37 static constexpr std::size_t count = 38 has_parameter_list && !is_count_out_of_range ? Count : 0; 39 40 using permissive_tuple = typename std::conditional< 41 has_parameter_list && !is_out_of_range, 42 args_tuple, std::tuple<error_t>>::type; 43 44 using permissive_function = typename std::conditional< 45 has_parameter_list && !is_out_of_range, 46 T, error_t(error_t)>::type; 47 }; 48 49 }}} // namespace boost::callable_traits::detail 50 51 #endif // #ifndef BOOST_CLBL_TRTS_PARAMETER_INDEX_HELPER_HPP 52