File indexing completed on 2025-01-18 09:29:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_CLBL_TRTS_SFINAE_ERRORS_HPP
0010 #define BOOST_CLBL_TRTS_SFINAE_ERRORS_HPP
0011
0012 #include <boost/callable_traits/detail/config.hpp>
0013
0014 namespace boost { namespace callable_traits { namespace detail {
0015
0016 struct sfinae_error{};
0017
0018 template<typename T>
0019 struct success {
0020 static constexpr bool value = true;
0021 struct _ { using type = T; };
0022 };
0023
0024 template<bool B, typename T>
0025 struct fail_if : T {
0026 static_assert(std::is_base_of<sfinae_error, T>::value,
0027 "incorrect usage of fail_if");
0028
0029 static constexpr bool value = B;
0030 };
0031
0032 template<typename T, typename... FailIfs>
0033 using sfinae_try = typename BOOST_CLBL_TRTS_DISJUNCTION(
0034 FailIfs..., success<T>)::_::type;
0035
0036 template<typename FailMsg, typename ForceTwoPhaseLookup>
0037 struct fail {
0038 using type = typename std::conditional<std::is_same<ForceTwoPhaseLookup, std::false_type>::value,
0039 FailMsg, FailMsg>::type::_::type;
0040 };
0041
0042 }}}
0043
0044 #define BOOST_CLBL_TRTS_PP_CAT_(x, y) x ## y
0045 #define BOOST_CLBL_TRTS_PP_CAT(x, y) BOOST_CLBL_TRTS_PP_CAT_(x, y)
0046
0047 #define BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(origin) \
0048 namespace error { \
0049 template<typename ErrorMessage> \
0050 struct origin : \
0051 ::boost::callable_traits::detail::sfinae_error \
0052 { struct _ {}; }; \
0053 } \
0054
0055
0056 #define BOOST_CLBL_TRTS_SFINAE_MSG(origin, name) \
0057 struct BOOST_CLBL_TRTS_PP_CAT(name, _ ){}; \
0058 struct name : error::origin< \
0059 BOOST_CLBL_TRTS_PP_CAT(name, _ )>{}; \
0060
0061
0062 namespace boost { namespace callable_traits {
0063
0064 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(parameters)
0065 BOOST_CLBL_TRTS_SFINAE_MSG(parameters, index_out_of_range_for_parameter_list)
0066 BOOST_CLBL_TRTS_SFINAE_MSG(parameters, cannot_determine_parameters_for_this_type)
0067
0068 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(varargs)
0069 BOOST_CLBL_TRTS_SFINAE_MSG(varargs, varargs_are_illegal_for_this_type)
0070
0071 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(member_qualifiers)
0072 BOOST_CLBL_TRTS_SFINAE_MSG(member_qualifiers, member_qualifiers_are_illegal_for_this_type)
0073 BOOST_CLBL_TRTS_SFINAE_MSG(member_qualifiers, this_compiler_doesnt_support_abominable_function_types)
0074
0075 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(transaction_safe_)
0076 BOOST_CLBL_TRTS_SFINAE_MSG(transaction_safe_, transaction_safe_is_not_supported_by_this_configuration)
0077
0078 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(expand_args)
0079 BOOST_CLBL_TRTS_SFINAE_MSG(expand_args, cannot_expand_the_parameter_list_of_first_template_argument)
0080
0081 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(member_pointer_required)
0082 BOOST_CLBL_TRTS_SFINAE_MSG(member_pointer_required, type_is_not_a_member_pointer)
0083
0084 BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(reference_error)
0085 BOOST_CLBL_TRTS_SFINAE_MSG(reference_error, reference_type_not_supported_by_this_metafunction)
0086
0087 }}
0088
0089 #endif