diff --git a/example/interface_example.cpp b/example/interface_example.cpp index d874f47..3164e61 100644 --- a/example/interface_example.cpp +++ b/example/interface_example.cpp @@ -12,7 +12,7 @@ See interface.hpp in this directory for details. #include #ifdef CALLABLE_TRAITS_MSVC int main(){ return 0; } -#elif defined CALLABLE_TRAITS_GCC_OLDER_THAN_4_9_2 +#elif defined CALLABLE_TRAITS_GCC_OLDER_THAN_5_0_0 int main(){ return 0; } #else diff --git a/include/callable_traits/add_member_const.hpp b/include/callable_traits/add_member_const.hpp index 3656496..fa6d74a 100644 --- a/include/callable_traits/add_member_const.hpp +++ b/include/callable_traits/add_member_const.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct add_member_const_error { - - static_assert(Sfinae, - "callable_traits::add_member_const " - "is not a meaningful operation for this T."); - }; - } - template struct add_member_const { using type = detail::fail_if_invalid< typename detail::traits::add_member_const, - detail::add_member_const_error>; + member_qualifiers_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/add_member_cv.hpp b/include/callable_traits/add_member_cv.hpp index 76f87d6..317958d 100644 --- a/include/callable_traits/add_member_cv.hpp +++ b/include/callable_traits/add_member_cv.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct add_member_cv_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::add_member_cv " - "is not a meaningful operation for this T."); - }; - } - template struct add_member_cv { using type = detail::fail_if_invalid< - typename detail::traits::add_member_cv, - detail::add_member_cv_error>; + typename detail::traits::add_member_cv, + member_qualifiers_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/add_member_lvalue_reference.hpp b/include/callable_traits/add_member_lvalue_reference.hpp index 15a3790..a5cca91 100644 --- a/include/callable_traits/add_member_lvalue_reference.hpp +++ b/include/callable_traits/add_member_lvalue_reference.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct add_member_lvalue_reference_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::add_member_lvalue_reference " - "is not a meaningful operation for this T."); - }; - } - template struct add_member_lvalue_reference { using type = detail::fail_if_invalid< typename detail::traits::add_member_lvalue_reference, - detail::add_member_lvalue_reference_error>; + member_qualifiers_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/add_member_rvalue_reference.hpp b/include/callable_traits/add_member_rvalue_reference.hpp index 84df857..53741a5 100644 --- a/include/callable_traits/add_member_rvalue_reference.hpp +++ b/include/callable_traits/add_member_rvalue_reference.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct add_member_rvalue_reference_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::add_member_rvalue_reference " - "is not a meaningful operation for this T."); - }; - } - template struct add_member_rvalue_reference { using type = detail::fail_if_invalid< typename detail::traits::add_member_rvalue_reference, - detail::add_member_rvalue_reference_error>; + member_qualifiers_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/add_member_volatile.hpp b/include/callable_traits/add_member_volatile.hpp index 13573be..d372e07 100644 --- a/include/callable_traits/add_member_volatile.hpp +++ b/include/callable_traits/add_member_volatile.hpp @@ -15,23 +15,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct add_member_volatile_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::add_member_volatile " - "is not a meaningful operation for this T."); - }; - } - template struct add_member_volatile { using type = detail::fail_if_invalid< typename detail::traits::add_member_volatile, - detail::add_member_volatile_error>; + member_qualifiers_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/add_varargs.hpp b/include/callable_traits/add_varargs.hpp index ffe948e..efca9b6 100644 --- a/include/callable_traits/add_varargs.hpp +++ b/include/callable_traits/add_varargs.hpp @@ -14,25 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct add_varargs_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::add_varargs is not " - "a meaningful operation for this T. T must " - "be a function, function pointer, function " - "reference, or member function pointer."); - }; - } - template struct add_varargs { using type = detail::fail_if_invalid< typename detail::traits::add_varargs, - detail::add_varargs_error>; + varargs_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/apply_return.hpp b/include/callable_traits/apply_return.hpp index adf2e36..7142d85 100644 --- a/include/callable_traits/apply_return.hpp +++ b/include/callable_traits/apply_return.hpp @@ -16,14 +16,6 @@ namespace callable_traits { namespace detail { - template - struct apply_return_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::apply_return is " - "not a meaningful operation for this T."); - }; - template struct apply_return_helper { using type = typename detail::traits::template apply_return; @@ -36,12 +28,18 @@ namespace callable_traits { }; } + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(apply_return) + + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(apply_return, + invalid_types_for_apply_return) + + template struct apply_return { using type = detail::fail_if_invalid< typename detail::apply_return_helper::type, - detail::apply_return_error>; + invalid_types_for_apply_return>; }; template diff --git a/include/callable_traits/arg_at.hpp b/include/callable_traits/arg_at.hpp index aa894c5..46531f6 100644 --- a/include/callable_traits/arg_at.hpp +++ b/include/callable_traits/arg_at.hpp @@ -15,21 +15,29 @@ Distributed under the Boost Software License, Version 1.0. #include namespace callable_traits { - - namespace detail { - struct arg_at_error : sfinae_error {}; - } template struct arg_at { - using type = detail::fail_if_invalid< - detail::weak_at::arg_types>, - detail::arg_at_error>; + private: + + using arg_types = typename args::type; + + public: + + // SFINAEs away if index is out of range or if argument + // types cannot be determined. Simple error messages are + // provided in case the error occurs outside of a SFINAE context + + using type = detail::sfinae_try< + + detail::at, + + detail::fail_if= std::tuple_size::value, + index_out_of_range_for_parameter_list> + >; }; - // returns callable_traits::invalid_type if - // index is out of range template using arg_at_t = typename arg_at::type; } diff --git a/include/callable_traits/args.hpp b/include/callable_traits/args.hpp index cae250d..eaaa1ad 100644 --- a/include/callable_traits/args.hpp +++ b/include/callable_traits/args.hpp @@ -14,26 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct args_error : sfinae_error { - - static_assert(Sfinae, - "Could not determine the parameters for " - "T in callable_traits::args. Note: " - "If T is the type of a generic lambda or " - " overloaded/templated function object, " - "the parameters cannot be determined. "); - }; - } - template struct args { using type = detail::fail_if_invalid< typename detail::traits::arg_types, - detail::args_error>; + cannot_determine_parameters_for_this_type>; }; template diff --git a/include/callable_traits/clear_args.hpp b/include/callable_traits/clear_args.hpp index c9be9d6..bce90d2 100644 --- a/include/callable_traits/clear_args.hpp +++ b/include/callable_traits/clear_args.hpp @@ -14,23 +14,17 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(clear_args) - template - struct clear_args_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::clear_args is " - "not a meaningful operation for this T."); - }; - } + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(clear_args, + cannot_clear_the_parameter_list_for_this_type) template struct clear_args { using type = detail::fail_if_invalid< typename detail::traits::clear_args, - detail::clear_args_error>; + cannot_clear_the_parameter_list_for_this_type>; }; template diff --git a/include/callable_traits/config.hpp b/include/callable_traits/config.hpp index 866d2fc..00c0769 100644 --- a/include/callable_traits/config.hpp +++ b/include/callable_traits/config.hpp @@ -14,16 +14,21 @@ Distributed under the Boost Software License, Version 1.0. #ifndef __clang__ #if defined __GNUC__ + #define CALLABLE_TRAITS_GCC - #if __GNUC__ >= 6 - #define CALLABLE_TRAITS_GCC_AT_LEAST_4_9_2 - #elif __GNUC__ >= 5 + + #if __GNUC__ < 5 + #define CALLABLE_TRAITS_GCC_OLDER_THAN_5_0_0 + #endif + + #if __GNUC__ >= 5 #define CALLABLE_TRAITS_GCC_AT_LEAST_4_9_2 #elif __GNUC__ == 4 && __GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ >= 2 #define CALLABLE_TRAITS_GCC_AT_LEAST_4_9_2 #else #define CALLABLE_TRAITS_GCC_OLDER_THAN_4_9_2 - #endif //#if __GNUC__ >= 6 + #endif //#if __GNUC__ >= 5 + #endif //#if defined __GNUC__ #endif //#ifndef __clang__ diff --git a/include/callable_traits/copy_qualifiers.hpp b/include/callable_traits/copy_qualifiers.hpp index 65b22f9..57c5144 100644 --- a/include/callable_traits/copy_qualifiers.hpp +++ b/include/callable_traits/copy_qualifiers.hpp @@ -15,15 +15,10 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(copy_qualifiers) - template - struct copy_qualifiers_error : sfinae_error { - - static_assert(Sfinae, - "TODO: error message for callable_traits::copy_qualifiers"); - }; - } + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(copy_qualifiers, + cannot_copy_qualifiers_for_these_types) template struct copy_qualifiers { @@ -31,7 +26,7 @@ namespace callable_traits { using type = detail::fail_if_invalid< typename detail::copy_qualifiers_impl< detail::traits, detail::traits>::type, - detail::copy_qualifiers_error>; + cannot_copy_qualifiers_for_these_types>; }; template diff --git a/include/callable_traits/detail/core.hpp b/include/callable_traits/detail/core.hpp index f684c2a..2aee925 100644 --- a/include/callable_traits/detail/core.hpp +++ b/include/callable_traits/detail/core.hpp @@ -10,8 +10,8 @@ Distributed under the Boost Software License, Version 1.0. #ifndef CALLABLE_TRAITS_DETAIL_CORE_HPP #define CALLABLE_TRAITS_DETAIL_CORE_HPP -#include #include +#include #include #include #include diff --git a/include/callable_traits/detail/function_object.hpp b/include/callable_traits/detail/function_object.hpp index dfa4c97..2ddba17 100644 --- a/include/callable_traits/detail/function_object.hpp +++ b/include/callable_traits/detail/function_object.hpp @@ -44,7 +44,7 @@ namespace callable_traits { using is_member_pointer = std::false_type; using is_member_function_pointer = std::false_type; - using remove_member_pointer = type; + using remove_member_pointer = invalid_type; using remove_varargs = invalid_type; using add_varargs = invalid_type; using clear_args = invalid_type; diff --git a/include/callable_traits/detail/sfinae_errors.hpp b/include/callable_traits/detail/sfinae_errors.hpp new file mode 100644 index 0000000..4d877c5 --- /dev/null +++ b/include/callable_traits/detail/sfinae_errors.hpp @@ -0,0 +1,91 @@ +/*! +@copyright Barrett Adair 2016 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +*/ + +#ifndef CALLABLE_TRAITS_SFINAE_ERRORS_HPP +#define CALLABLE_TRAITS_SFINAE_ERRORS_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + struct sfinae_error{}; + + template + struct success { + static constexpr bool value = true; + struct _ { using type = T; }; + }; + + template + struct fail_if : T { + + static_assert(std::is_base_of::value, + "incorrect usage of fail_if"); + + static constexpr bool value = B; + }; + + template + using sfinae_try = typename CALLABLE_TRAITS_DISJUNCTION( + ThrowIfs..., + success + )::_::type; + } + +#define CALLABLE_TRAITS_PP_CAT_(x, y) x ## y +#define CALLABLE_TRAITS_PP_CAT(x, y) CALLABLE_TRAITS_PP_CAT_(x, y) + +#define CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(origin) \ +namespace callable_traits_ERROR { \ + template \ + struct origin : \ + ::callable_traits::detail::sfinae_error \ + { struct _ {}; }; \ +} \ +/**/ + +#define CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(origin, name) \ +struct CALLABLE_TRAITS_PP_CAT(name, _ ){}; \ +struct name : callable_traits_ERROR::origin< \ + CALLABLE_TRAITS_PP_CAT(name, _ )>{}; \ +/**/ + + /*** parameter manipulation errors ***/ + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(parameters) + + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(parameters, + index_out_of_range_for_parameter_list) + + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(parameters, + cannot_determine_parameters_for_this_type) + + + /*** parent class errors ***/ + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(parent_class) + + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(parent_class, + type_is_not_a_member_pointer) + + + /*** member qualifier errors ***/ + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(member_qualifiers) + + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(member_qualifiers, + member_qualifiers_are_illegal_for_this_type) + + + /*** varargs errors ***/ + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(varargs) + + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(varargs, + varargs_are_illegal_for_this_type) +} +#endif // #ifndef CALLABLE_TRAITS_SFINAE_ERRORS_HPP diff --git a/include/callable_traits/detail/unguarded/args_pack_manipulations.hpp b/include/callable_traits/detail/unguarded/args_pack_manipulations.hpp index d9616d7..54ec63b 100644 --- a/include/callable_traits/detail/unguarded/args_pack_manipulations.hpp +++ b/include/callable_traits/detail/unguarded/args_pack_manipulations.hpp @@ -28,14 +28,14 @@ struct insert_impl; template struct insert_impl, StartTo> { - static_assert(StartTo <= arg_count, "Insert index out of range"); - - using type = + using type = sfinae_try< CALLABLE_TRAITS_BEGIN_PACK_MANIP typename std::tuple_element< map_insert::value, std::tuple>::type... - CALLABLE_TRAITS_END_PACK_MANIP; + CALLABLE_TRAITS_END_PACK_MANIP, + + >; }; template @@ -58,15 +58,14 @@ struct remove_impl; template struct remove_impl { - static_assert(Index < arg_count, - "Remove index out of range"); - - using type = + using type = sfinae_try< CALLABLE_TRAITS_BEGIN_PACK_MANIP typename std::tuple_element< map_remove::value, std::tuple>::type... - CALLABLE_TRAITS_END_PACK_MANIP; + CALLABLE_TRAITS_END_PACK_MANIP, + + >; }; //when not removing anything @@ -100,14 +99,14 @@ struct overwrite_impl; template struct overwrite_impl, StartTo> { - static_assert(StartTo <= arg_count, "Insert index out of range"); - - using type = + using type = sfinae_try< CALLABLE_TRAITS_BEGIN_PACK_MANIP typename std::tuple_element< map_overwrite::value, std::tuple>::type... - CALLABLE_TRAITS_END_PACK_MANIP; + CALLABLE_TRAITS_END_PACK_MANIP, + + >; }; template diff --git a/include/callable_traits/detail/unguarded/function.hpp b/include/callable_traits/detail/unguarded/function.hpp index f5fd23c..a6ba621 100644 --- a/include/callable_traits/detail/unguarded/function.hpp +++ b/include/callable_traits/detail/unguarded/function.hpp @@ -25,6 +25,7 @@ struct function using remove_varargs = type; using add_varargs = Return (Args..., ...) CALLABLE_TRAITS_INCLUDE_QUALIFIERS; + // todo is this really necessary? using has_member_qualifiers_function = bool_type< !std::is_same::value>; diff --git a/include/callable_traits/detail/utility.hpp b/include/callable_traits/detail/utility.hpp index c5d1c37..12ab497 100644 --- a/include/callable_traits/detail/utility.hpp +++ b/include/callable_traits/detail/utility.hpp @@ -10,6 +10,7 @@ Distributed under the Boost Software License, Version 1.0. #ifndef CALLABLE_TRAITS_DETAIL_UTILITY_HPP #define CALLABLE_TRAITS_DETAIL_UTILITY_HPP +#include #include #include #include @@ -35,29 +36,6 @@ namespace callable_traits { template using at = typename std::tuple_element::type; - - namespace util_detail { - - template - struct weak_at_t { - using type = at; - }; - - template - struct weak_at_t= std::tuple_size::value>>{ - using type = invalid_type; - }; - - template - struct weak_at_t{ - using type = invalid_type; - }; - } - - // bounds-checked version of at (see above) - template - using weak_at = typename util_detail::weak_at_t::type; - // a faster version of std::decay_t template using shallow_decay = typename std::remove_cv< @@ -105,10 +83,6 @@ namespace callable_traits { using remove_member_pointer = typename util_detail::remove_member_pointer_t::type; - struct sfinae_error { - struct _ {}; - }; - namespace util_detail { template struct type_value { @@ -120,11 +94,9 @@ namespace callable_traits { }; } - template - using fail_if_invalid = typename CALLABLE_TRAITS_DISJUNCTION( - util_detail::type_value::value>, - FailType - )::_::type; + template + using fail_if_invalid = sfinae_try::value, ErrorType>>; template using fallback_if_invalid = typename std::conditional< diff --git a/include/callable_traits/expand_args.hpp b/include/callable_traits/expand_args.hpp index ea3fde4..8db3b7f 100644 --- a/include/callable_traits/expand_args.hpp +++ b/include/callable_traits/expand_args.hpp @@ -14,22 +14,17 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(expand_args) - template - struct expand_args_error { - - static_assert(Sfinae, - "callable_traits::expand_args is not a valid operation."); - }; - } + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(expand_args, + cannot_expand_the_parameter_list_of_first_template_argument) template class Container> struct expand_args { using type = detail::fail_if_invalid< typename detail::traits::template expand_args, - detail::expand_args_error>; + cannot_expand_the_parameter_list_of_first_template_argument>; }; template class Container> diff --git a/include/callable_traits/insert_args.hpp b/include/callable_traits/insert_args.hpp index ed39725..f0a2d32 100644 --- a/include/callable_traits/insert_args.hpp +++ b/include/callable_traits/insert_args.hpp @@ -14,22 +14,11 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct insert_args_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::push_back is " - "not a meaningful operation for this T."); - }; - } - template struct insert_args { using type = detail::fail_if_invalid< typename detail::traits::template insert_args, - detail::insert_args_error>; + cannot_determine_parameters_for_this_type>; }; template diff --git a/include/callable_traits/parent_class_of.hpp b/include/callable_traits/parent_class_of.hpp index 73d0a4a..1aa233d 100644 --- a/include/callable_traits/parent_class_of.hpp +++ b/include/callable_traits/parent_class_of.hpp @@ -14,22 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct parent_class_of_error : sfinae_error { - - static_assert(Sfinae, - "TODO: error message for callable_traits::parent_class_of"); - }; - } - template struct parent_class_of { using type = detail::fail_if_invalid< typename detail::traits::class_type, - detail::parent_class_of_error>; + type_is_not_a_member_pointer>; }; template diff --git a/include/callable_traits/pop_back.hpp b/include/callable_traits/pop_back.hpp index a68ada0..c3b860f 100644 --- a/include/callable_traits/pop_back.hpp +++ b/include/callable_traits/pop_back.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct args_pop_back_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::args_push_back is " - "not a meaningful operation for this T."); - }; - } - template struct args_pop_back { using type = detail::fail_if_invalid< typename detail::traits::template pop_back, - detail::args_pop_back_error>; + cannot_determine_parameters_for_this_type>; }; template diff --git a/include/callable_traits/pop_front.hpp b/include/callable_traits/pop_front.hpp index acafffe..a37ac78 100644 --- a/include/callable_traits/pop_front.hpp +++ b/include/callable_traits/pop_front.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct args_pop_front_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::push_back is " - "not a meaningful operation for this T."); - }; - } - template struct args_pop_front { using type = detail::fail_if_invalid< typename detail::traits::template pop_front, - detail::args_pop_front_error>; + cannot_determine_parameters_for_this_type>; }; diff --git a/include/callable_traits/push_back.hpp b/include/callable_traits/push_back.hpp index 271c968..c410b73 100644 --- a/include/callable_traits/push_back.hpp +++ b/include/callable_traits/push_back.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct args_push_back_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::push_back is " - "not a meaningful operation for this T."); - }; - } - template struct args_push_back { using type = detail::fail_if_invalid< typename detail::traits::template push_back, - detail::args_push_back_error>; + cannot_determine_parameters_for_this_type>; }; template diff --git a/include/callable_traits/push_front.hpp b/include/callable_traits/push_front.hpp index 55c2cd7..19f7941 100644 --- a/include/callable_traits/push_front.hpp +++ b/include/callable_traits/push_front.hpp @@ -30,7 +30,7 @@ namespace callable_traits { using type = detail::fail_if_invalid< typename detail::traits::template push_front, - detail::args_push_front_error>; + cannot_determine_parameters_for_this_type>; }; template diff --git a/include/callable_traits/qualified_parent_class_of.hpp b/include/callable_traits/qualified_parent_class_of.hpp index 6b2eed6..8909f49 100644 --- a/include/callable_traits/qualified_parent_class_of.hpp +++ b/include/callable_traits/qualified_parent_class_of.hpp @@ -14,22 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct qualified_parent_class_of_error : sfinae_error { - - static_assert(Sfinae, - "TODO: error message for callable_traits::qualified_parent_class_of"); - }; - } - template struct qualified_parent_class_of { using type = detail::fail_if_invalid< typename detail::traits::invoke_type, - detail::qualified_parent_class_of_error>; + type_is_not_a_member_pointer>; }; template diff --git a/include/callable_traits/remove_args.hpp b/include/callable_traits/remove_args.hpp index 8ddb37a..ec5f906 100644 --- a/include/callable_traits/remove_args.hpp +++ b/include/callable_traits/remove_args.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct remove_args_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::push_back is " - "not a meaningful operation for this T."); - }; - } - template struct remove_args { using type = detail::fail_if_invalid< typename detail::traits::template remove_args, - detail::remove_args_error>; + cannot_determine_parameters_for_this_type>; }; template diff --git a/include/callable_traits/remove_member_const.hpp b/include/callable_traits/remove_member_const.hpp index 83e61b4..0a9ae4d 100644 --- a/include/callable_traits/remove_member_const.hpp +++ b/include/callable_traits/remove_member_const.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct remove_member_const_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::remove_member_const " - "is not a meaningful operation for this T."); - }; - } - template struct remove_member_const { using type = detail::fail_if_invalid< typename detail::traits::remove_member_const, - detail::remove_member_const_error>; + member_qualifiers_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/remove_member_cv.hpp b/include/callable_traits/remove_member_cv.hpp index b883c92..a717cbe 100644 --- a/include/callable_traits/remove_member_cv.hpp +++ b/include/callable_traits/remove_member_cv.hpp @@ -15,23 +15,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct remove_member_cv_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::remove_member_cv " - "is not a meaningful operation for this T."); - }; - } - template struct remove_member_cv { using type = detail::fail_if_invalid< typename detail::traits::remove_member_cv, - detail::remove_member_cv_error>; + member_qualifiers_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/remove_member_pointer.hpp b/include/callable_traits/remove_member_pointer.hpp index 6301fac..27ca87f 100644 --- a/include/callable_traits/remove_member_pointer.hpp +++ b/include/callable_traits/remove_member_pointer.hpp @@ -14,23 +14,17 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(remove_member_pointer) - template - struct remove_member_pointer_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::remove_member_pointer " - "is not a meaningful operation for this T."); - }; - } + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(remove_member_pointer, + cannot_remove_member_pointer_from_this_type) template struct remove_member_pointer { using type = detail::fail_if_invalid< typename detail::traits::remove_member_pointer, - detail::remove_member_pointer_error>; + cannot_remove_member_pointer_from_this_type>; }; template diff --git a/include/callable_traits/remove_varargs.hpp b/include/callable_traits/remove_varargs.hpp index 822fb05..145240a 100644 --- a/include/callable_traits/remove_varargs.hpp +++ b/include/callable_traits/remove_varargs.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct remove_varargs_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::remove_varargs " - "is not a meaningful operation for this T."); - }; - } - template struct remove_varargs { using type = detail::fail_if_invalid< typename detail::traits::remove_varargs, - detail::remove_varargs_error>; + varargs_are_illegal_for_this_type>; }; template diff --git a/include/callable_traits/replace_args.hpp b/include/callable_traits/replace_args.hpp index d3273b7..f12bd13 100644 --- a/include/callable_traits/replace_args.hpp +++ b/include/callable_traits/replace_args.hpp @@ -14,23 +14,12 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { - - template - struct replace_args_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::push_back is " - "not a meaningful operation for this T."); - }; - } - template struct replace_args { using type = detail::fail_if_invalid< typename detail::traits::template replace_args, - detail::replace_args_error>; + cannot_determine_parameters_for_this_type>; }; template diff --git a/include/callable_traits/result_of.hpp b/include/callable_traits/result_of.hpp index 3fe7c4d..fd914a4 100644 --- a/include/callable_traits/result_of.hpp +++ b/include/callable_traits/result_of.hpp @@ -14,23 +14,17 @@ Distributed under the Boost Software License, Version 1.0. namespace callable_traits { - namespace detail { + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_ORIGIN(result_of) - template - struct result_of_error : sfinae_error { - - static_assert(Sfinae, - "callable_traits::result_of is not " - "a meaningful operation for this T."); - }; - } + CALLABLE_TRAITS_DEFINE_SFINAE_ERROR_FOR(result_of, + unable_to_determine_return_type) template struct result_of { using type = detail::fail_if_invalid< typename detail::traits::return_type, - detail::result_of_error>; + unable_to_determine_return_type>; }; template diff --git a/test/detail/args_pack_manipulations.cpp b/test/detail/args_pack_manipulations.cpp index 499b732..41b9a15 100644 --- a/test/detail/args_pack_manipulations.cpp +++ b/test/detail/args_pack_manipulations.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #ifndef CT_ASSERT #define CT_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)