From 9bacc225fb9d2b7ea085dfddab0d4e594d3498ac Mon Sep 17 00:00:00 2001 From: badair Date: Wed, 6 Apr 2016 18:12:59 -0500 Subject: [PATCH] removing is_overloaded, using one header per trait --- doc/callable_traits.qbk | 10 +- example/ambiguity.cpp | 6 +- example/intro.cpp | 8 +- .../callable_traits/add_const_qualifier.hpp | 34 ++ include/callable_traits/add_cv_qualifiers.hpp | 34 ++ .../callable_traits/add_lvalue_qualifier.hpp | 34 ++ .../callable_traits/add_rvalue_qualifier.hpp | 34 ++ include/callable_traits/add_varargs.hpp | 34 ++ .../add_volatile_qualifier.hpp | 34 ++ .../callable_traits/apply_member_pointer.hpp | 34 ++ include/callable_traits/apply_return.hpp | 34 ++ include/callable_traits/arg_at.hpp | 22 ++ include/callable_traits/args.hpp | 37 ++ include/callable_traits/arity.hpp | 31 ++ include/callable_traits/bind.hpp | 26 ++ include/callable_traits/callable_traits.hpp | 46 ++- include/callable_traits/can_invoke.hpp | 25 ++ .../callable_traits/can_invoke_constexpr.hpp | 25 ++ include/callable_traits/detail/arity.hpp | 5 - .../detail/bind_expression_parser.hpp | 3 +- .../detail/categorize_bind_arg.hpp | 2 +- include/callable_traits/detail/function.hpp | 2 +- .../detail/function_object.hpp | 6 +- include/callable_traits/detail/traits.hpp | 2 +- include/callable_traits/detail/utility.hpp | 17 +- include/callable_traits/function_type.hpp | 35 ++ include/callable_traits/has_varargs.hpp | 31 ++ include/callable_traits/has_void_return.hpp | 31 ++ include/callable_traits/interface.hpp | 369 ------------------ .../callable_traits/is_const_qualified.hpp | 30 ++ include/callable_traits/is_constexpr.hpp | 33 ++ include/callable_traits/is_cv_qualified.hpp | 30 ++ .../callable_traits/is_lvalue_qualified.hpp | 30 ++ .../is_reference_qualified.hpp | 30 ++ .../callable_traits/is_rvalue_qualified.hpp | 30 ++ include/callable_traits/is_unqualified.hpp | 30 ++ .../callable_traits/is_volatile_qualified.hpp | 30 ++ include/callable_traits/max_arity.hpp | 33 ++ include/callable_traits/min_arity.hpp | 33 ++ .../no_sfinae/add_const_qualifier.hpp | 25 ++ .../no_sfinae/add_cv_qualifiers.hpp | 25 ++ .../no_sfinae/add_lvalue_qualifier.hpp | 29 ++ .../no_sfinae/add_rvalue_qualifier.hpp | 25 ++ .../callable_traits/no_sfinae/add_varargs.hpp | 25 ++ .../no_sfinae/add_volatile_qualifier.hpp | 25 ++ .../no_sfinae/apply_member_pointer.hpp | 25 ++ .../no_sfinae/apply_return.hpp | 25 ++ include/callable_traits/no_sfinae/arg_at.hpp | 25 ++ include/callable_traits/no_sfinae/args.hpp | 25 ++ .../no_sfinae/function_type.hpp | 24 ++ .../no_sfinae/qualified_function_type.hpp | 30 ++ .../no_sfinae/remove_const_qualifier.hpp | 25 ++ .../no_sfinae/remove_cv_qualifiers.hpp | 29 ++ .../no_sfinae/remove_member_pointer.hpp | 25 ++ .../no_sfinae/remove_reference_qualifier.hpp | 25 ++ .../no_sfinae/remove_varargs.hpp | 25 ++ .../no_sfinae/remove_volatile_qualifier.hpp | 29 ++ .../callable_traits/no_sfinae/result_of.hpp | 27 ++ .../qualified_function_type.hpp | 35 ++ .../remove_const_qualifier.hpp | 34 ++ .../callable_traits/remove_cv_qualifiers.hpp | 34 ++ .../callable_traits/remove_member_pointer.hpp | 34 ++ .../remove_reference_qualifier.hpp | 34 ++ include/callable_traits/remove_varargs.hpp | 34 ++ .../remove_volatile_qualifier.hpp | 34 ++ include/callable_traits/result_of.hpp | 34 ++ qtcreator/include/include.pro | 1 + qtcreator/main/main.cpp | 55 ++- test/pmf_qualifiers.cpp | 96 ++--- 69 files changed, 1760 insertions(+), 478 deletions(-) create mode 100644 include/callable_traits/add_const_qualifier.hpp create mode 100644 include/callable_traits/add_cv_qualifiers.hpp create mode 100644 include/callable_traits/add_lvalue_qualifier.hpp create mode 100644 include/callable_traits/add_rvalue_qualifier.hpp create mode 100644 include/callable_traits/add_varargs.hpp create mode 100644 include/callable_traits/add_volatile_qualifier.hpp create mode 100644 include/callable_traits/apply_member_pointer.hpp create mode 100644 include/callable_traits/apply_return.hpp create mode 100644 include/callable_traits/arg_at.hpp create mode 100644 include/callable_traits/args.hpp create mode 100644 include/callable_traits/arity.hpp create mode 100644 include/callable_traits/bind.hpp create mode 100644 include/callable_traits/can_invoke.hpp create mode 100644 include/callable_traits/can_invoke_constexpr.hpp create mode 100644 include/callable_traits/function_type.hpp create mode 100644 include/callable_traits/has_varargs.hpp create mode 100644 include/callable_traits/has_void_return.hpp delete mode 100644 include/callable_traits/interface.hpp create mode 100644 include/callable_traits/is_const_qualified.hpp create mode 100644 include/callable_traits/is_constexpr.hpp create mode 100644 include/callable_traits/is_cv_qualified.hpp create mode 100644 include/callable_traits/is_lvalue_qualified.hpp create mode 100644 include/callable_traits/is_reference_qualified.hpp create mode 100644 include/callable_traits/is_rvalue_qualified.hpp create mode 100644 include/callable_traits/is_unqualified.hpp create mode 100644 include/callable_traits/is_volatile_qualified.hpp create mode 100644 include/callable_traits/max_arity.hpp create mode 100644 include/callable_traits/min_arity.hpp create mode 100644 include/callable_traits/no_sfinae/add_const_qualifier.hpp create mode 100644 include/callable_traits/no_sfinae/add_cv_qualifiers.hpp create mode 100644 include/callable_traits/no_sfinae/add_lvalue_qualifier.hpp create mode 100644 include/callable_traits/no_sfinae/add_rvalue_qualifier.hpp create mode 100644 include/callable_traits/no_sfinae/add_varargs.hpp create mode 100644 include/callable_traits/no_sfinae/add_volatile_qualifier.hpp create mode 100644 include/callable_traits/no_sfinae/apply_member_pointer.hpp create mode 100644 include/callable_traits/no_sfinae/apply_return.hpp create mode 100644 include/callable_traits/no_sfinae/arg_at.hpp create mode 100644 include/callable_traits/no_sfinae/args.hpp create mode 100644 include/callable_traits/no_sfinae/function_type.hpp create mode 100644 include/callable_traits/no_sfinae/qualified_function_type.hpp create mode 100644 include/callable_traits/no_sfinae/remove_const_qualifier.hpp create mode 100644 include/callable_traits/no_sfinae/remove_cv_qualifiers.hpp create mode 100644 include/callable_traits/no_sfinae/remove_member_pointer.hpp create mode 100644 include/callable_traits/no_sfinae/remove_reference_qualifier.hpp create mode 100644 include/callable_traits/no_sfinae/remove_varargs.hpp create mode 100644 include/callable_traits/no_sfinae/remove_volatile_qualifier.hpp create mode 100644 include/callable_traits/no_sfinae/result_of.hpp create mode 100644 include/callable_traits/qualified_function_type.hpp create mode 100644 include/callable_traits/remove_const_qualifier.hpp create mode 100644 include/callable_traits/remove_cv_qualifiers.hpp create mode 100644 include/callable_traits/remove_member_pointer.hpp create mode 100644 include/callable_traits/remove_reference_qualifier.hpp create mode 100644 include/callable_traits/remove_varargs.hpp create mode 100644 include/callable_traits/remove_volatile_qualifier.hpp create mode 100644 include/callable_traits/result_of.hpp diff --git a/doc/callable_traits.qbk b/doc/callable_traits.qbk index aea9186..914a450 100644 --- a/doc/callable_traits.qbk +++ b/doc/callable_traits.qbk @@ -49,8 +49,6 @@ CallableTraits contains the following type traits and metafunctions (psuedo-code * `can_invoke_constexpr(T&&, Args&&...)` * `is_constexpr(T&&)` * `is_constexpr()` -* `is_overloaded(T&&)` -* `is_overloaded()` * `has_varargs(T&&)` * `has_varargs()` * `has_void_return(T&&)` @@ -71,10 +69,10 @@ CallableTraits contains the following type traits and metafunctions (psuedo-code * `is_cv_qualified()` * `is_reference_qualified(T&&)` * `is_reference_qualified()` -* `is_lvalue_reference_qualified(T&&)` -* `is_lvalue_reference_qualified()` -* `is_rvalue_reference_qualified(T&&)` -* `is_rvalue_reference_qualified()` +* `is_lvalue_qualified(T&&)` +* `is_lvalue_qualified()` +* `is_rvalue_qualified(T&&)` +* `is_rvalue_qualified()` [*Template aliases] diff --git a/example/ambiguity.cpp b/example/ambiguity.cpp index d7ea130..aee694b 100644 --- a/example/ambiguity.cpp +++ b/example/ambiguity.cpp @@ -20,15 +20,15 @@ int main() { { using test = ct::no_sfinae::args; - using expect = std::tuple; + using expect = ct::invalid_type; static_assert(std::is_same{}, ""); } { using test = ct::no_sfinae::function_type; - using expect = ct::unknown(ct::unknown); + using expect = ct::invalid_type; static_assert(std::is_same{}, ""); } { using test = ct::no_sfinae::result_of; - using expect = ct::unknown; + using expect = ct::invalid_type; static_assert(std::is_same{}, ""); } diff --git a/example/intro.cpp b/example/intro.cpp index 9bf763e..5a607f1 100644 --- a/example/intro.cpp +++ b/example/intro.cpp @@ -71,10 +71,6 @@ int main() { // C-style varargs (ellipses in a signature) can be detected. static_assert(!ct::has_varargs(foo{}), ""); - // callable_traits::is_overloaded yields std::true_type - // for function objects that have overloaded or templated operator() - static_assert(!ct::is_overloaded(foo{}), ""); - // callable_traits::can_invoke allows us to preview whether // std::invoke will compile with the given arguments. Keep // in mind that failing cases must be SFINAE-friendly (i.e. @@ -112,8 +108,8 @@ int main() { static_assert(ct::is_const_qualified(foo{}), ""); static_assert(!ct::is_volatile_qualified(foo{}), ""); static_assert(!ct::is_reference_qualified(foo{}), ""); - static_assert(!ct::is_lvalue_reference_qualified(foo{}), ""); - static_assert(!ct::is_rvalue_reference_qualified(foo{}), ""); + static_assert(!ct::is_lvalue_qualified(foo{}), ""); + static_assert(!ct::is_lvalue_qualified(foo{}), ""); diff --git a/include/callable_traits/add_const_qualifier.hpp b/include/callable_traits/add_const_qualifier.hpp new file mode 100644 index 0000000..28f9886 --- /dev/null +++ b/include/callable_traits/add_const_qualifier.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ADD_CONST_QUALIFIER_HPP +#define CALLABLE_TRAITS_ADD_CONST_QUALIFIER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct add_const_qualifier_error { + static_assert(i != 0, + "callable_traits::add_const_qualifier is not a meaningful operation for this T."); + }; + } + + template + using add_const_qualifier = detail::fail_if_invalid< + no_sfinae::add_const_qualifier, + detail::add_const_qualifier_error<> + >; +} + +#endif diff --git a/include/callable_traits/add_cv_qualifiers.hpp b/include/callable_traits/add_cv_qualifiers.hpp new file mode 100644 index 0000000..8b41eed --- /dev/null +++ b/include/callable_traits/add_cv_qualifiers.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ADD_CV_QUALIFIERS_HPP +#define CALLABLE_TRAITS_ADD_CV_QUALIFIERS_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct add_cv_qualifiers_error { + static_assert(i != 0, + "callable_traits::add_cv_qualifiers is not a meaningful operation for this T."); + }; + } + + template + using add_cv_qualifiers = detail::fail_if_invalid< + no_sfinae::add_cv_qualifiers, + detail::add_cv_qualifiers_error<> + >; +} + +#endif diff --git a/include/callable_traits/add_lvalue_qualifier.hpp b/include/callable_traits/add_lvalue_qualifier.hpp new file mode 100644 index 0000000..1b1e0b3 --- /dev/null +++ b/include/callable_traits/add_lvalue_qualifier.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ADD_LVALUE_QUALIFIER_HPP +#define CALLABLE_TRAITS_ADD_LVALUE_QUALIFIER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct add_lvalue_qualifier_error { + static_assert(i != 0, + "callable_traits::add_lvalue_qualifier is not a meaningful operation for this T."); + }; + } + + template + using add_lvalue_qualifier = detail::fail_if_invalid< + no_sfinae::add_lvalue_qualifier, + detail::add_lvalue_qualifier_error<> + >; +} + +#endif diff --git a/include/callable_traits/add_rvalue_qualifier.hpp b/include/callable_traits/add_rvalue_qualifier.hpp new file mode 100644 index 0000000..b7bcfb8 --- /dev/null +++ b/include/callable_traits/add_rvalue_qualifier.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ADD_RVALUE_QUALIFIER_HPP +#define CALLABLE_TRAITS_ADD_RVALUE_QUALIFIER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct add_rvalue_qualifier_error { + static_assert(i != 0, + "callable_traits::add_rvalue_qualifier is not a meaningful operation for this T."); + }; + } + + template + using add_rvalue_qualifier = detail::fail_if_invalid< + no_sfinae::add_rvalue_qualifier, + detail::add_rvalue_qualifier_error<> + >; +} + +#endif diff --git a/include/callable_traits/add_varargs.hpp b/include/callable_traits/add_varargs.hpp new file mode 100644 index 0000000..ad55e9c --- /dev/null +++ b/include/callable_traits/add_varargs.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ADD_VARARGS_HPP +#define CALLABLE_TRAITS_ADD_VARARGS_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct add_varargs_error { + static_assert(i != 0, + "callable_traits::add_varargs is not a meaningful operation for this T."); + }; + } + + template + using add_varargs = detail::fail_if_invalid< + no_sfinae::add_varargs, + detail::add_varargs_error<> + >; +} + +#endif diff --git a/include/callable_traits/add_volatile_qualifier.hpp b/include/callable_traits/add_volatile_qualifier.hpp new file mode 100644 index 0000000..f5f5572 --- /dev/null +++ b/include/callable_traits/add_volatile_qualifier.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ADD_VOLATILE_QUALIFIER_HPP +#define CALLABLE_TRAITS_ADD_VOLATILE_QUALIFIER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct add_volatile_qualifier_error { + static_assert(i != 0, + "callable_traits::add_volatile_qualifier is not a meaningful operation for this T."); + }; + } + + template + using add_volatile_qualifier = detail::fail_if_invalid< + no_sfinae::add_volatile_qualifier, + detail::add_volatile_qualifier_error<> + >; +} + +#endif diff --git a/include/callable_traits/apply_member_pointer.hpp b/include/callable_traits/apply_member_pointer.hpp new file mode 100644 index 0000000..fbf8c89 --- /dev/null +++ b/include/callable_traits/apply_member_pointer.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_APPLY_MEMBER_POINTER_HPP +#define CALLABLE_TRAITS_APPLY_MEMBER_POINTER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct apply_member_pointer_error { + static_assert(i != 0, + "callable_traits::apply_member_pointer is not a meaningful operation for this T."); + }; + } + + template + using apply_member_pointer = detail::fail_if_invalid< + typename no_sfinae::apply_member_pointer, + detail::apply_member_pointer_error<> + >; +} + +#endif diff --git a/include/callable_traits/apply_return.hpp b/include/callable_traits/apply_return.hpp new file mode 100644 index 0000000..df790aa --- /dev/null +++ b/include/callable_traits/apply_return.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_APPLY_RETURN_HPP +#define CALLABLE_TRAITS_APPLY_RETURN_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct apply_return_error { + static_assert(i != 0, + "callable_traits::apply_return is not a meaningful operation for this T."); + }; + } + + template + using apply_return = detail::fail_if_invalid< + typename no_sfinae::apply_return, + detail::apply_return_error<> + >; +} + +#endif diff --git a/include/callable_traits/arg_at.hpp b/include/callable_traits/arg_at.hpp new file mode 100644 index 0000000..6218f91 --- /dev/null +++ b/include/callable_traits/arg_at.hpp @@ -0,0 +1,22 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ARG_AT_HPP +#define CALLABLE_TRAITS_ARG_AT_HPP + +#include +#include + +namespace callable_traits { + + template + using arg_at = typename std::tuple_element>::type; +} + +#endif diff --git a/include/callable_traits/args.hpp b/include/callable_traits/args.hpp new file mode 100644 index 0000000..797edf7 --- /dev/null +++ b/include/callable_traits/args.hpp @@ -0,0 +1,37 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ARGS_HPP +#define CALLABLE_TRAITS_ARGS_HPP + +#include +#include +#include + +#include +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct args_error { + static_assert(i != 0, + "Unable to determine arguments of type T in callable_traits::args."); + }; + } + + template + using args = detail::fail_if_invalid, detail::args_error<>>; + +} + +#endif diff --git a/include/callable_traits/arity.hpp b/include/callable_traits/arity.hpp new file mode 100644 index 0000000..3c32e1b --- /dev/null +++ b/include/callable_traits/arity.hpp @@ -0,0 +1,31 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_ARITY_HPP +#define CALLABLE_TRAITS_ARITY_HPP + +#include +#include + +namespace callable_traits { + + template + inline constexpr auto + arity(T&&) { + return detail::arity_t>{}; + } + + template + inline constexpr auto + arity() { + return detail::arity_t>{}; + } +} + +#endif diff --git a/include/callable_traits/bind.hpp b/include/callable_traits/bind.hpp new file mode 100644 index 0000000..2423cba --- /dev/null +++ b/include/callable_traits/bind.hpp @@ -0,0 +1,26 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_BIND_HPP +#define CALLABLE_TRAITS_BIND_HPP + +#include +#include +#include + +namespace callable_traits { + + template + inline constexpr auto + bind(T&& t, Args&&... args) -> detail::bind_expression { + return {::std::forward(t), ::std::forward(args)...}; + } +} + +#endif diff --git a/include/callable_traits/callable_traits.hpp b/include/callable_traits/callable_traits.hpp index 96631a4..52583f0 100644 --- a/include/callable_traits/callable_traits.hpp +++ b/include/callable_traits/callable_traits.hpp @@ -10,17 +10,39 @@ Distributed under the Boost Software License, Version 1.0. #ifndef CALLABLE_TRAITS_CALLABLE_TRAITS_HPP #define CALLABLE_TRAITS_CALLABLE_TRAITS_HPP -#ifdef _MSVC_VER -#pragma warning(push) -// disabling the MSVC warning about symbol truncation. This is -// harmless, because none of these symbols are involved in linking. -#pragma warning(disable : 4503) -#endif //ifdef _MSVC_VER - -#include - -#ifdef _MSVC_VER -#pragma warning(pop) -#endif //ifdef _MSVC_VER +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif diff --git a/include/callable_traits/can_invoke.hpp b/include/callable_traits/can_invoke.hpp new file mode 100644 index 0000000..cd1c111 --- /dev/null +++ b/include/callable_traits/can_invoke.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_CAN_INVOKE_HPP +#define CALLABLE_TRAITS_CAN_INVOKE_HPP + +#include +#include + +namespace callable_traits { + + template + inline constexpr auto + can_invoke(Args&&... args) { + return detail::can_invoke_impl(std::forward(args)...); + } +} + +#endif diff --git a/include/callable_traits/can_invoke_constexpr.hpp b/include/callable_traits/can_invoke_constexpr.hpp new file mode 100644 index 0000000..a373fe0 --- /dev/null +++ b/include/callable_traits/can_invoke_constexpr.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_CAN_INVOKE_CONSTEXPR_HPP +#define CALLABLE_TRAITS_CAN_INVOKE_CONSTEXPR_HPP + +#include +#include + +namespace callable_traits { + + template + inline constexpr auto + can_invoke_constexpr(Args&&... args) { + return detail::can_invoke_constexpr_impl(std::forward(args)...); + } +} + +#endif diff --git a/include/callable_traits/detail/arity.hpp b/include/callable_traits/detail/arity.hpp index 9e528de..4f02738 100644 --- a/include/callable_traits/detail/arity.hpp +++ b/include/callable_traits/detail/arity.hpp @@ -92,11 +92,6 @@ namespace callable_traits { static constexpr int value = -1; }; - template<> - struct arg_tuple_size> { - static constexpr int value = -1; - }; - template struct arg_tuple_size> { static constexpr int value = sizeof...(T); diff --git a/include/callable_traits/detail/bind_expression_parser.hpp b/include/callable_traits/detail/bind_expression_parser.hpp index c3970db..98425e0 100644 --- a/include/callable_traits/detail/bind_expression_parser.hpp +++ b/include/callable_traits/detail/bind_expression_parser.hpp @@ -56,7 +56,6 @@ namespace callable_traits { static constexpr const auto is_legal_arg = !std::is_same>{} - && !std::is_same{} && !std::is_same{}; using type = typename std::conditional< @@ -74,7 +73,7 @@ namespace callable_traits { using filtered_args = typename filter_invalid_args::type; using type = typename std::conditional< std::is_same>::value, - std::tuple, + invalid_type, filtered_args >::type; }; diff --git a/include/callable_traits/detail/categorize_bind_arg.hpp b/include/callable_traits/detail/categorize_bind_arg.hpp index f32e95d..46b6650 100644 --- a/include/callable_traits/detail/categorize_bind_arg.hpp +++ b/include/callable_traits/detail/categorize_bind_arg.hpp @@ -53,7 +53,7 @@ namespace callable_traits { using return_type = typename bind_expression::return_type; using type = typename std::conditional< - std::is_same::value, + std::is_same::value, any_arg<>, return_type >::type; diff --git a/include/callable_traits/detail/function.hpp b/include/callable_traits/detail/function.hpp index 389ba7e..ad35b96 100644 --- a/include/callable_traits/detail/function.hpp +++ b/include/callable_traits/detail/function.hpp @@ -139,7 +139,7 @@ namespace callable_traits { namespace detail { template - struct function : function_object> { + struct function : function_object> { static constexpr const bool value = false; using traits = function; }; diff --git a/include/callable_traits/detail/function_object.hpp b/include/callable_traits/detail/function_object.hpp index d678469..98e255e 100644 --- a/include/callable_traits/detail/function_object.hpp +++ b/include/callable_traits/detail/function_object.hpp @@ -48,10 +48,10 @@ namespace callable_traits { template struct ambiguous_function_object { - using arg_types = std::tuple; - using return_type = unknown; + using arg_types = invalid_type; + using return_type = invalid_type; using has_varargs = std::false_type; - using function_type = unknown(unknown); + using function_type = invalid_type; using function_object_type = function_type; }; diff --git a/include/callable_traits/detail/traits.hpp b/include/callable_traits/detail/traits.hpp index 2bb2cba..c2ef968 100644 --- a/include/callable_traits/detail/traits.hpp +++ b/include/callable_traits/detail/traits.hpp @@ -31,7 +31,7 @@ namespace callable_traits { shallow_decay, T >::type; - + template using traits = typename disjunction< bind_expression_traits>, diff --git a/include/callable_traits/detail/utility.hpp b/include/callable_traits/detail/utility.hpp index 8eaae4c..21a4c77 100644 --- a/include/callable_traits/detail/utility.hpp +++ b/include/callable_traits/detail/utility.hpp @@ -24,9 +24,6 @@ struct constants { struct invalid_type { invalid_type() = delete; }; -struct unknown { unknown() = delete; }; - - namespace detail { // used to convey "this type doesn't matter" in code @@ -267,6 +264,20 @@ struct unknown { unknown() = delete; }; >::type; + namespace util_detail { + template + struct type_value { + static constexpr const bool value = Value; + using type = T; + }; + } + + template + using fail_if_invalid = typename disjunction< + util_detail::type_value::value>, + FailType + >::type; + //used to prepend a type to a tuple template struct prepend; diff --git a/include/callable_traits/function_type.hpp b/include/callable_traits/function_type.hpp new file mode 100644 index 0000000..0a38cf7 --- /dev/null +++ b/include/callable_traits/function_type.hpp @@ -0,0 +1,35 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_FUNCTION_TYPE_HPP +#define CALLABLE_TRAITS_FUNCTION_TYPE_HPP + +#include +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct function_type_error { + static_assert(i != 0, + "Unable to determine a function type for type T in callable_traits::function_type."); + }; + } + + template + using function_type = detail::fail_if_invalid< + no_sfinae::function_type, + detail::function_type_error<> + >; +} + +#endif diff --git a/include/callable_traits/has_varargs.hpp b/include/callable_traits/has_varargs.hpp new file mode 100644 index 0000000..56ce076 --- /dev/null +++ b/include/callable_traits/has_varargs.hpp @@ -0,0 +1,31 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_HAS_VARARGS_HPP +#define CALLABLE_TRAITS_HAS_VARARGS_HPP + +#include +#include + +namespace callable_traits { + + template + inline constexpr auto + has_varargs(T&&) { + return typename detail::traits::has_varargs{}; + } + + template + inline constexpr auto + has_varargs() { + return typename detail::traits::has_varargs{}; + } +} + +#endif diff --git a/include/callable_traits/has_void_return.hpp b/include/callable_traits/has_void_return.hpp new file mode 100644 index 0000000..d89646f --- /dev/null +++ b/include/callable_traits/has_void_return.hpp @@ -0,0 +1,31 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_HAS_VOID_RETURN_HPP +#define CALLABLE_TRAITS_HAS_VOID_RETURN_HPP + +#include +#include + +namespace callable_traits { + + template + inline constexpr auto + has_void_return(T&&) { + return typename std::is_same, void>::type{}; + } + + template + inline constexpr auto + has_void_return() { + return typename std::is_same, void>::type{}; + } +} + +#endif diff --git a/include/callable_traits/interface.hpp b/include/callable_traits/interface.hpp deleted file mode 100644 index d158a60..0000000 --- a/include/callable_traits/interface.hpp +++ /dev/null @@ -1,369 +0,0 @@ -/*! -@file - -@copyright Barrett Adair 2015 -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_INTERFACE_HPP -#define CALLABLE_TRAITS_INTERFACE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace callable_traits { - - namespace no_sfinae { - - template - using args = typename detail::traits::arg_types; - - template - using arg_at = detail::weak_at>; - - template - using function_type = typename detail::traits::function_type; - - template - using qualified_function_type = typename detail::traits::abominable_type; - - template - using result_of = typename detail::traits::return_type; - - template - using remove_const_qualifier = - typename detail::traits::remove_const; - - template - using remove_volatile_qualifier = - typename detail::traits::remove_volatile; - - template - using remove_cv_qualifiers = - typename detail::traits::remove_cv; - - template - using remove_reference_qualifier = - typename detail::traits::remove_reference; - - template - using remove_varargs = - typename detail::traits::remove_varargs; - - template - using remove_member_pointer = - typename detail::traits::remove_member_pointer; - - template - using add_const_qualifier = - typename detail::traits::add_const; - - template - using add_volatile_qualifier = - typename detail::traits::add_volatile; - - template - using add_cv_qualifiers = - typename detail::traits::add_cv; - - template - using add_lvalue_qualifier = - typename detail::traits::add_lvalue_reference; - - template - using add_rvalue_qualifier = - typename detail::traits::add_rvalue_reference; - - template - using add_varargs = - typename detail::traits::add_varargs; - - template - using apply_member_pointer = - typename detail::traits::template apply_member_pointer; - - template - using apply_return = - typename detail::traits::template apply_return; - } - - namespace detail { - - template - using if_valid = typename std::enable_if< - !std::is_same::value - && !std::is_same::value - && !std::is_same>::value - && !std::is_same::value, - T - >::type; - } - - template - using args = detail::if_valid>; - - template - using arg_at = detail::at>; - - template - using function_type = detail::if_valid>; - - template - using qualified_function_type = detail::if_valid>; - - template - using result_of = detail::if_valid>; - - template - using remove_const_qualifier = detail::if_valid>; - - template - using remove_volatile_qualifier = detail::if_valid>; - - template - using remove_cv_qualifiers = detail::if_valid>; - - template - using remove_reference_qualifier = detail::if_valid>; - - template - using remove_varargs = detail::if_valid>; - - template - using remove_member_pointer = detail::if_valid>; - - template - using add_const_qualifier = detail::if_valid>; - - template - using add_volatile_qualifier = detail::if_valid>; - - template - using add_cv_qualifiers = detail::if_valid>; - - template - using add_lvalue_qualifier = detail::if_valid>; - - template - using add_rvalue_qualifier = detail::if_valid>; - - template - using add_varargs = detail::if_valid>; - - template - using apply_member_pointer = - detail::if_valid>; - - template - using apply_return = - detail::if_valid>; - - template - inline constexpr auto - can_invoke(Args&&... args) { - return detail::can_invoke_impl(std::forward(args)...); - } - - template - inline constexpr auto - can_invoke_constexpr(Args&&... args) { - return detail::can_invoke_constexpr_impl(std::forward(args)...); - } - - template - inline constexpr auto - is_constexpr(T&& t){ - using can_construct = detail::is_constexpr_constructible; - return detail::is_constexpr_impl(std::forward(t), can_construct{}); - } - - template - inline constexpr auto - is_constexpr(){ - return decltype(is_constexpr(std::declval())){}; - } - - template - inline constexpr auto - is_overloaded(T&&) { - return typename detail::traits::is_ambiguous{}; - } - - template - inline constexpr auto - is_overloaded() { - return typename detail::traits::is_ambiguous{}; - } - - template - inline constexpr auto - has_varargs(T&&) { - return typename detail::traits::has_varargs{}; - } - - template - inline constexpr auto - has_varargs() { - return typename detail::traits::has_varargs{}; - } - - template - inline constexpr auto - has_void_return(T&&) { - return typename std::is_same, void>::type{}; - } - - template - inline constexpr auto - has_void_return() { - return typename std::is_same, void>::type{}; - } - - template< std::size_t SearchLimit = constants::arity_search_limit, typename T> - inline constexpr auto - min_arity(T&&) { - return detail::min_arity_t, SearchLimit>{}; - } - - template - inline constexpr auto - min_arity() { - return detail::min_arity_t, SearchLimit>{}; - } - - template - inline constexpr auto - max_arity(T&&) { - return detail::max_arity_t, SearchLimit>{}; - } - - template - inline constexpr auto - max_arity() { - return detail::max_arity_t, SearchLimit>{}; - } - - template - inline constexpr auto - arity(T&&) { - return detail::arity_t>{}; - } - - template - inline constexpr auto - arity() { - return detail::arity_t>{}; - } - - template - inline constexpr auto - bind(T&& t, Args&&... args) -> detail::bind_expression { - return {::std::forward(t), ::std::forward(args)...}; - } - - template - inline constexpr auto - is_unqualified() { - return typename detail::traits::is_unqualified{}; - } - - template - inline constexpr auto - is_unqualified(T&&) { - return typename detail::traits::is_unqualified{}; - } - - template - inline constexpr auto - is_const_qualified() { - return typename detail::traits::is_const_qualified{}; - } - - template - inline constexpr auto - is_const_qualified(T&&) { - return typename detail::traits::is_const_qualified{}; - } - - template - inline constexpr auto - is_cv_qualified() { - return typename detail::traits::is_cv_qualified{}; - } - - template - inline constexpr auto - is_cv_qualified(T&&) { - return typename detail::traits::is_cv_qualified{}; - } - - template - inline constexpr auto - is_volatile_qualified() { - return typename detail::traits::is_volatile_qualified{}; - } - - template - inline constexpr auto - is_volatile_qualified(T&&) { - return typename detail::traits::is_volatile_qualified{}; - } - - template - inline constexpr auto - is_reference_qualified() { - return typename detail::traits::is_reference_qualified{}; - } - - template - inline constexpr auto - is_reference_qualified(T&&) { - return typename detail::traits::is_reference_qualified{}; - } - - template - inline constexpr auto - is_lvalue_reference_qualified() { - return typename detail::traits::is_lvalue_reference_qualified{}; - } - - template - inline constexpr auto - is_lvalue_reference_qualified(T&&) { - return typename detail::traits::is_lvalue_reference_qualified{}; - } - - template - inline constexpr auto - is_rvalue_reference_qualified() { - return typename detail::traits::is_rvalue_reference_qualified{}; - } - - template - inline constexpr auto - is_rvalue_reference_qualified(T&&) { - return typename detail::traits::is_rvalue_reference_qualified{}; - } -} - -#ifdef _MSVC_VER -#pragma warning(pop) -#endif //ifdef _MSVC_VER - -#endif diff --git a/include/callable_traits/is_const_qualified.hpp b/include/callable_traits/is_const_qualified.hpp new file mode 100644 index 0000000..8fff698 --- /dev/null +++ b/include/callable_traits/is_const_qualified.hpp @@ -0,0 +1,30 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_IS_CONST_QUALIFIED_HPP +#define CALLABLE_TRAITS_IS_CONST_QUALIFIED_HPP + +#include + +namespace callable_traits { + + template + inline constexpr auto + is_const_qualified() { + return typename detail::traits::is_const_qualified{}; + } + + template + inline constexpr auto + is_const_qualified(T&&) { + return typename detail::traits::is_const_qualified{}; + } +} + +#endif diff --git a/include/callable_traits/is_constexpr.hpp b/include/callable_traits/is_constexpr.hpp new file mode 100644 index 0000000..9827c40 --- /dev/null +++ b/include/callable_traits/is_constexpr.hpp @@ -0,0 +1,33 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_IS_CONSTEXPR_HPP +#define CALLABLE_TRAITS_IS_CONSTEXPR_HPP + +#include +#include +#include + +namespace callable_traits { + + template + inline constexpr auto + is_constexpr(T&& t){ + using can_construct = detail::is_constexpr_constructible; + return detail::is_constexpr_impl(std::forward(t), can_construct{}); + } + + template + inline constexpr auto + is_constexpr(){ + return decltype(is_constexpr(std::declval())){}; + } +} + +#endif diff --git a/include/callable_traits/is_cv_qualified.hpp b/include/callable_traits/is_cv_qualified.hpp new file mode 100644 index 0000000..6e6587f --- /dev/null +++ b/include/callable_traits/is_cv_qualified.hpp @@ -0,0 +1,30 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_IS_CV_QUALIFIED_HPP +#define CALLABLE_TRAITS_IS_CV_QUALIFIED_HPP + +#include + +namespace callable_traits { + + template + inline constexpr auto + is_cv_qualified() { + return typename detail::traits::is_cv_qualified{}; + } + + template + inline constexpr auto + is_cv_qualified(T&&) { + return typename detail::traits::is_cv_qualified{}; + } +} + +#endif diff --git a/include/callable_traits/is_lvalue_qualified.hpp b/include/callable_traits/is_lvalue_qualified.hpp new file mode 100644 index 0000000..ec9e8f3 --- /dev/null +++ b/include/callable_traits/is_lvalue_qualified.hpp @@ -0,0 +1,30 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_IS_LVALUE_QUALIFIED_HPP +#define CALLABLE_TRAITS_IS_LVALUE_QUALIFIED_HPP + +#include + +namespace callable_traits { + + template + inline constexpr auto + is_lvalue_qualified() { + return typename detail::traits::is_lvalue_reference_qualified{}; + } + + template + inline constexpr auto + is_lvalue_qualified(T&&) { + return typename detail::traits::is_lvalue_reference_qualified{}; + } +} + +#endif diff --git a/include/callable_traits/is_reference_qualified.hpp b/include/callable_traits/is_reference_qualified.hpp new file mode 100644 index 0000000..71baffd --- /dev/null +++ b/include/callable_traits/is_reference_qualified.hpp @@ -0,0 +1,30 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_IS_REFERENCE_QUALIFIED_HPP +#define CALLABLE_TRAITS_IS_REFERENCE_QUALIFIED_HPP + +#include + +namespace callable_traits { + + template + inline constexpr auto + is_reference_qualified() { + return typename detail::traits::is_reference_qualified{}; + } + + template + inline constexpr auto + is_reference_qualified(T&&) { + return typename detail::traits::is_reference_qualified{}; + } +} + +#endif diff --git a/include/callable_traits/is_rvalue_qualified.hpp b/include/callable_traits/is_rvalue_qualified.hpp new file mode 100644 index 0000000..2fe401b --- /dev/null +++ b/include/callable_traits/is_rvalue_qualified.hpp @@ -0,0 +1,30 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_IS_RVALUE_QUALIFIED_HPP +#define CALLABLE_TRAITS_IS_RVALUE_QUALIFIED_HPP + +#include + +namespace callable_traits { + + template + inline constexpr auto + is_rvalue_qualified() { + return typename detail::traits::is_rvalue_reference_qualified{}; + } + + template + inline constexpr auto + is_rvalue_qualified(T&&) { + return typename detail::traits::is_rvalue_reference_qualified{}; + } +} + +#endif diff --git a/include/callable_traits/is_unqualified.hpp b/include/callable_traits/is_unqualified.hpp new file mode 100644 index 0000000..eb0d121 --- /dev/null +++ b/include/callable_traits/is_unqualified.hpp @@ -0,0 +1,30 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_IS_UNQUALIFIED_HPP +#define CALLABLE_TRAITS_IS_UNQUALIFIED_HPP + +#include + +namespace callable_traits { + + template + inline constexpr auto + is_unqualified() { + return typename detail::traits::is_unqualified{}; + } + + template + inline constexpr auto + is_unqualified(T&&) { + return typename detail::traits::is_unqualified{}; + } +} + +#endif diff --git a/include/callable_traits/is_volatile_qualified.hpp b/include/callable_traits/is_volatile_qualified.hpp new file mode 100644 index 0000000..94fc67a --- /dev/null +++ b/include/callable_traits/is_volatile_qualified.hpp @@ -0,0 +1,30 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_IS_VOLATILE_QUALIFIED_HPP +#define CALLABLE_TRAITS_IS_VOLATILE_QUALIFIED_HPP + +#include + +namespace callable_traits { + + template + inline constexpr auto + is_volatile_qualified() { + return typename detail::traits::is_volatile_qualified{}; + } + + template + inline constexpr auto + is_volatile_qualified(T&&) { + return typename detail::traits::is_volatile_qualified{}; + } +} + +#endif diff --git a/include/callable_traits/max_arity.hpp b/include/callable_traits/max_arity.hpp new file mode 100644 index 0000000..90f5b97 --- /dev/null +++ b/include/callable_traits/max_arity.hpp @@ -0,0 +1,33 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_MAX_ARITY_HPP +#define CALLABLE_TRAITS_MAX_ARITY_HPP + +#include +#include +#include +#include + +namespace callable_traits { + + template + inline constexpr auto + max_arity(T&&) { + return detail::max_arity_t, SearchLimit>{}; + } + + template + inline constexpr auto + max_arity() { + return detail::max_arity_t, SearchLimit>{}; + } +} + +#endif diff --git a/include/callable_traits/min_arity.hpp b/include/callable_traits/min_arity.hpp new file mode 100644 index 0000000..f5d3de8 --- /dev/null +++ b/include/callable_traits/min_arity.hpp @@ -0,0 +1,33 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_MIN_ARITY_HPP +#define CALLABLE_TRAITS_MIN_ARITY_HPP + +#include +#include +#include +#include + +namespace callable_traits { + + template< std::size_t SearchLimit = constants::arity_search_limit, typename T> + inline constexpr auto + min_arity(T&&) { + return detail::min_arity_t, SearchLimit>{}; + } + + template + inline constexpr auto + min_arity() { + return detail::min_arity_t, SearchLimit>{}; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/add_const_qualifier.hpp b/include/callable_traits/no_sfinae/add_const_qualifier.hpp new file mode 100644 index 0000000..75effc2 --- /dev/null +++ b/include/callable_traits/no_sfinae/add_const_qualifier.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_ADD_CONST_QUALIFIER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_ADD_CONST_QUALIFIER_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using add_const_qualifier = + typename detail::traits::add_const; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/add_cv_qualifiers.hpp b/include/callable_traits/no_sfinae/add_cv_qualifiers.hpp new file mode 100644 index 0000000..e7a63ff --- /dev/null +++ b/include/callable_traits/no_sfinae/add_cv_qualifiers.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_ADD_CV_QUALIFIERS_HPP +#define CALLABLE_TRAITS_NO_SFINAE_ADD_CV_QUALIFIERS_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using add_cv_qualifiers = + typename detail::traits::add_cv; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/add_lvalue_qualifier.hpp b/include/callable_traits/no_sfinae/add_lvalue_qualifier.hpp new file mode 100644 index 0000000..ec44509 --- /dev/null +++ b/include/callable_traits/no_sfinae/add_lvalue_qualifier.hpp @@ -0,0 +1,29 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_ADD_LVALUE_QUALIFIER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_ADD_LVALUE_QUALIFIER_HPP + +#include + +#include +#include +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using add_lvalue_qualifier = + typename detail::traits::add_lvalue_reference; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/add_rvalue_qualifier.hpp b/include/callable_traits/no_sfinae/add_rvalue_qualifier.hpp new file mode 100644 index 0000000..ba95c2f --- /dev/null +++ b/include/callable_traits/no_sfinae/add_rvalue_qualifier.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_ADD_RVALUE_QUALIFIER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_ADD_RVALUE_QUALIFIER_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using add_rvalue_qualifier = + typename detail::traits::add_rvalue_reference; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/add_varargs.hpp b/include/callable_traits/no_sfinae/add_varargs.hpp new file mode 100644 index 0000000..a1e4c7a --- /dev/null +++ b/include/callable_traits/no_sfinae/add_varargs.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_ADD_VARARGS_HPP +#define CALLABLE_TRAITS_NO_SFINAE_ADD_VARARGS_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using add_varargs = + typename detail::traits::add_varargs; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/add_volatile_qualifier.hpp b/include/callable_traits/no_sfinae/add_volatile_qualifier.hpp new file mode 100644 index 0000000..e310cfb --- /dev/null +++ b/include/callable_traits/no_sfinae/add_volatile_qualifier.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_ADD_VOLATILE_QUALIFIER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_ADD_VOLATILE_QUALIFIER_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using add_volatile_qualifier = + typename detail::traits::add_volatile; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/apply_member_pointer.hpp b/include/callable_traits/no_sfinae/apply_member_pointer.hpp new file mode 100644 index 0000000..a2ee8c9 --- /dev/null +++ b/include/callable_traits/no_sfinae/apply_member_pointer.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_APPLY_MEMBER_POINTER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_APPLY_MEMBER_POINTER_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using apply_member_pointer = + typename detail::traits::template apply_member_pointer; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/apply_return.hpp b/include/callable_traits/no_sfinae/apply_return.hpp new file mode 100644 index 0000000..3cf1f70 --- /dev/null +++ b/include/callable_traits/no_sfinae/apply_return.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_APPLY_RETURN_HPP +#define CALLABLE_TRAITS_NO_SFINAE_APPLY_RETURN_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using apply_return = + typename detail::traits::template apply_return; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/arg_at.hpp b/include/callable_traits/no_sfinae/arg_at.hpp new file mode 100644 index 0000000..fd29370 --- /dev/null +++ b/include/callable_traits/no_sfinae/arg_at.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_ARG_AT_HPP +#define CALLABLE_TRAITS_NO_SFINAE_ARG_AT_HPP + +#include +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using arg_at = detail::weak_at>; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/args.hpp b/include/callable_traits/no_sfinae/args.hpp new file mode 100644 index 0000000..f982823 --- /dev/null +++ b/include/callable_traits/no_sfinae/args.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_ARGS_HPP +#define CALLABLE_TRAITS_NO_SFINAE_ARGS_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using args = typename detail::traits::arg_types; + + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/function_type.hpp b/include/callable_traits/no_sfinae/function_type.hpp new file mode 100644 index 0000000..4940e1c --- /dev/null +++ b/include/callable_traits/no_sfinae/function_type.hpp @@ -0,0 +1,24 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_FUNCTION_TYPE_HPP +#define CALLABLE_TRAITS_NO_SFINAE_FUNCTION_TYPE_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using function_type = typename detail::traits::function_type; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/qualified_function_type.hpp b/include/callable_traits/no_sfinae/qualified_function_type.hpp new file mode 100644 index 0000000..f965d9c --- /dev/null +++ b/include/callable_traits/no_sfinae/qualified_function_type.hpp @@ -0,0 +1,30 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_QUALIFIED_FUNCTION_TYPE_HPP +#define CALLABLE_TRAITS_NO_SFINAE_QUALIFIED_FUNCTION_TYPE_HPP + +#include + +#include +#include +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using qualified_function_type = + typename detail::traits::abominable_type; + + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/remove_const_qualifier.hpp b/include/callable_traits/no_sfinae/remove_const_qualifier.hpp new file mode 100644 index 0000000..a9c7cc3 --- /dev/null +++ b/include/callable_traits/no_sfinae/remove_const_qualifier.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_REMOVE_CONST_QUALIFIER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_REMOVE_CONST_QUALIFIER_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using remove_const_qualifier = + typename detail::traits::remove_const; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/remove_cv_qualifiers.hpp b/include/callable_traits/no_sfinae/remove_cv_qualifiers.hpp new file mode 100644 index 0000000..618672b --- /dev/null +++ b/include/callable_traits/no_sfinae/remove_cv_qualifiers.hpp @@ -0,0 +1,29 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_REMOVE_CV_QUALIFIERS_HPP +#define CALLABLE_TRAITS_NO_SFINAE_REMOVE_CV_QUALIFIERS_HPP + +#include + +#include +#include +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using remove_cv_qualifiers = + typename detail::traits::remove_cv; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/remove_member_pointer.hpp b/include/callable_traits/no_sfinae/remove_member_pointer.hpp new file mode 100644 index 0000000..1e421ef --- /dev/null +++ b/include/callable_traits/no_sfinae/remove_member_pointer.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_REMOVE_MEMBER_POINTER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_REMOVE_MEMBER_POINTER_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using remove_member_pointer = + typename detail::traits::remove_member_pointer; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/remove_reference_qualifier.hpp b/include/callable_traits/no_sfinae/remove_reference_qualifier.hpp new file mode 100644 index 0000000..a5035c9 --- /dev/null +++ b/include/callable_traits/no_sfinae/remove_reference_qualifier.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_REMOVE_REFERENCE_QUALIFIER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_REMOVE_REFERENCE_QUALIFIER_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using remove_reference_qualifier = + typename detail::traits::remove_reference; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/remove_varargs.hpp b/include/callable_traits/no_sfinae/remove_varargs.hpp new file mode 100644 index 0000000..4fcd760 --- /dev/null +++ b/include/callable_traits/no_sfinae/remove_varargs.hpp @@ -0,0 +1,25 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_REMOVE_VARARGS_HPP +#define CALLABLE_TRAITS_NO_SFINAE_REMOVE_VARARGS_HPP + +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using remove_varargs = + typename detail::traits::remove_varargs; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/remove_volatile_qualifier.hpp b/include/callable_traits/no_sfinae/remove_volatile_qualifier.hpp new file mode 100644 index 0000000..c2b4bb5 --- /dev/null +++ b/include/callable_traits/no_sfinae/remove_volatile_qualifier.hpp @@ -0,0 +1,29 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_REMOVE_VOLATILE_QUALIFIER_HPP +#define CALLABLE_TRAITS_NO_SFINAE_REMOVE_VOLATILE_QUALIFIER_HPP + +#include + +#include +#include +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using remove_volatile_qualifier = + typename detail::traits::remove_volatile; + } +} + +#endif diff --git a/include/callable_traits/no_sfinae/result_of.hpp b/include/callable_traits/no_sfinae/result_of.hpp new file mode 100644 index 0000000..3560caf --- /dev/null +++ b/include/callable_traits/no_sfinae/result_of.hpp @@ -0,0 +1,27 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_NO_SFINAE_RESULT_OF_HPP +#define CALLABLE_TRAITS_NO_SFINAE_RESULT_OF_HPP + +#include +#include +#include +#include + +namespace callable_traits { + + namespace no_sfinae { + + template + using result_of = typename detail::traits::return_type; + } +} + +#endif diff --git a/include/callable_traits/qualified_function_type.hpp b/include/callable_traits/qualified_function_type.hpp new file mode 100644 index 0000000..9f8caa2 --- /dev/null +++ b/include/callable_traits/qualified_function_type.hpp @@ -0,0 +1,35 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_QUALIFIED_FUNCTION_TYPE_HPP +#define CALLABLE_TRAITS_QUALIFIED_FUNCTION_TYPE_HPP + +#include +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct qualified_function_type_error { + static_assert(i != 0, + "Unable to determine the qualified function type for type T in callable_traits::qualified_function_type."); + }; + } + + template + using qualified_function_type = detail::fail_if_invalid< + no_sfinae::qualified_function_type, + detail::qualified_function_type_error<> + >; +} + +#endif diff --git a/include/callable_traits/remove_const_qualifier.hpp b/include/callable_traits/remove_const_qualifier.hpp new file mode 100644 index 0000000..9d3b8ba --- /dev/null +++ b/include/callable_traits/remove_const_qualifier.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_REMOVE_CONST_QUALIFIER_HPP +#define CALLABLE_TRAITS_REMOVE_CONST_QUALIFIER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct remove_const_qualifier_error { + static_assert(i != 0, + "callable_traits::remove_const_qualifier is not a meaningful operation for this T."); + }; + } + + template + using remove_const_qualifier = detail::fail_if_invalid< + no_sfinae::remove_const_qualifier, + detail::remove_const_qualifier_error<> + >; +} + +#endif diff --git a/include/callable_traits/remove_cv_qualifiers.hpp b/include/callable_traits/remove_cv_qualifiers.hpp new file mode 100644 index 0000000..903d730 --- /dev/null +++ b/include/callable_traits/remove_cv_qualifiers.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_REMOVE_CV_QUALIFIERS_HPP +#define CALLABLE_TRAITS_REMOVE_CV_QUALIFIERS_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct remove_cv_qualifiers_error { + static_assert(i != 0, + "callable_traits::remove_cv_qualifiers is not a meaningful operation for this T."); + }; + } + + template + using remove_cv_qualifiers = detail::fail_if_invalid< + no_sfinae::remove_cv_qualifiers, + detail::remove_cv_qualifiers_error<> + >; +} + +#endif diff --git a/include/callable_traits/remove_member_pointer.hpp b/include/callable_traits/remove_member_pointer.hpp new file mode 100644 index 0000000..777f1f6 --- /dev/null +++ b/include/callable_traits/remove_member_pointer.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_REMOVE_MEMBER_POINTER_HPP +#define CALLABLE_TRAITS_REMOVE_MEMBER_POINTER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct remove_member_pointer_error { + static_assert(i != 0, + "callable_traits::remove_member_pointer is not a meaningful operation for this T."); + }; + } + + template + using remove_member_pointer = detail::fail_if_invalid< + no_sfinae::remove_member_pointer, + detail::remove_member_pointer_error<> + >; +} + +#endif diff --git a/include/callable_traits/remove_reference_qualifier.hpp b/include/callable_traits/remove_reference_qualifier.hpp new file mode 100644 index 0000000..334e51a --- /dev/null +++ b/include/callable_traits/remove_reference_qualifier.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_REMOVE_REFERENCE_QUALIFIER_HPP +#define CALLABLE_TRAITS_REMOVE_REFERENCE_QUALIFIER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct remove_reference_qualifier_error { + static_assert(i != 0, + "callable_traits::remove_reference_qualifier is not a meaningful operation for this T."); + }; + } + + template + using remove_reference_qualifier = detail::fail_if_invalid< + no_sfinae::remove_reference_qualifier, + detail::remove_reference_qualifier_error<> + >; +} + +#endif diff --git a/include/callable_traits/remove_varargs.hpp b/include/callable_traits/remove_varargs.hpp new file mode 100644 index 0000000..6e4f8d1 --- /dev/null +++ b/include/callable_traits/remove_varargs.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_REMOVE_VARARGS_HPP +#define CALLABLE_TRAITS_REMOVE_VARARGS_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct remove_varargs_error { + static_assert(i != 0, + "callable_traits::remove_varargs is not a meaningful operation for this T."); + }; + } + + template + using remove_varargs = detail::fail_if_invalid< + no_sfinae::remove_varargs, + detail::remove_varargs_error<> + >; +} + +#endif diff --git a/include/callable_traits/remove_volatile_qualifier.hpp b/include/callable_traits/remove_volatile_qualifier.hpp new file mode 100644 index 0000000..b2765d8 --- /dev/null +++ b/include/callable_traits/remove_volatile_qualifier.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_REMOVE_VOLATILE_QUALIFIER_HPP +#define CALLABLE_TRAITS_REMOVE_VOLATILE_QUALIFIER_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct remove_volatile_qualifier_error { + static_assert(i != 0, + "callable_traits::remove_volatile_qualifier is not a meaningful operation for this T."); + }; + } + + template + using remove_volatile_qualifier = detail::fail_if_invalid< + no_sfinae::remove_volatile_qualifier, + detail::remove_volatile_qualifier_error<> + >; +} + +#endif diff --git a/include/callable_traits/result_of.hpp b/include/callable_traits/result_of.hpp new file mode 100644 index 0000000..ea06903 --- /dev/null +++ b/include/callable_traits/result_of.hpp @@ -0,0 +1,34 @@ +/*! +@file + +@copyright Barrett Adair 2015 +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_RESULT_OF_HPP +#define CALLABLE_TRAITS_RESULT_OF_HPP + +#include +#include + +namespace callable_traits { + + namespace detail { + + template + struct result_of_error { + static_assert(i != 0, + "Unable to determine the return type of T in callable_traits::result_of."); + }; + } + + template + using result_of = detail::fail_if_invalid< + no_sfinae::result_of, + detail::result_of_error<> + >; +} + +#endif diff --git a/qtcreator/include/include.pro b/qtcreator/include/include.pro index 92cd535..28a4b31 100644 --- a/qtcreator/include/include.pro +++ b/qtcreator/include/include.pro @@ -2,4 +2,5 @@ TEMPLATE = aux CONFIG -= qt HEADERS += ../../include/callable_traits/*.hpp HEADERS += ../../include/callable_traits/detail/*.hpp +HEADERS += ../../include/callable_traits/no_sfinae/*.hpp HEADERS += ../../include/callable_traits/detail/fwd/*.hpp diff --git a/qtcreator/main/main.cpp b/qtcreator/main/main.cpp index 5ebaab4..a645a21 100644 --- a/qtcreator/main/main.cpp +++ b/qtcreator/main/main.cpp @@ -1,34 +1,53 @@ -/*! -Copyright (c) 2016 Barrett Adair +/* +Copyright Barrett Adair 2015 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ -#include +#include +#include "../example/std_function/make_function.hpp" -namespace ct = callable_traits; +using example::make_function; +using namespace std::placeholders; -using expect = int; +int add(int i, int j) { + return i + j; +} -struct foo; +struct adder { -template -void test() { - using result = ct::result_of; - static_assert(std::is_same{}, ""); + int eval(int i, int j) const { + return i + j; + } +}; + +void check_add(std::function f) { + + auto add_result = f(99, 1); + assert(add_result == 100); } int main() { - test(); - test(); - test(); - test(); - test(); + //function pointer + auto f = make_function(&add); + check_add(f); - auto x = []() -> int { return 0; }; + //function reference + f = make_function(add); + check_add(f); - test(); + //lambda + f = make_function([](int i, int j) { + return i + j; + }); + + check_add(f); + + //member function pointer (bound to object) + f = make_function(&adder::eval, adder{}, _1, _2); + + check_add(f); } - diff --git a/test/pmf_qualifiers.cpp b/test/pmf_qualifiers.cpp index 7841a0d..228b469 100644 --- a/test/pmf_qualifiers.cpp +++ b/test/pmf_qualifiers.cpp @@ -159,54 +159,54 @@ CT_ASSERT(ct::is_reference_qualified(pmf_cvl{})); CT_ASSERT(ct::is_reference_qualified()); CT_ASSERT(ct::is_reference_qualified(pmf_cvr{})); -CT_ASSERT(!ct::is_lvalue_reference_qualified()); -CT_ASSERT(!ct::is_lvalue_reference_qualified(pmf{})); -CT_ASSERT(ct::is_lvalue_reference_qualified()); -CT_ASSERT(ct::is_lvalue_reference_qualified(pmf_l{})); -CT_ASSERT(!ct::is_lvalue_reference_qualified()); -CT_ASSERT(!ct::is_lvalue_reference_qualified(pmf_r{})); -CT_ASSERT(!ct::is_lvalue_reference_qualified()); -CT_ASSERT(!ct::is_lvalue_reference_qualified(pmf_c{})); -CT_ASSERT(ct::is_lvalue_reference_qualified()); -CT_ASSERT(ct::is_lvalue_reference_qualified(pmf_cl{})); -CT_ASSERT(!ct::is_lvalue_reference_qualified()); -CT_ASSERT(!ct::is_lvalue_reference_qualified(pmf_cr{})); -CT_ASSERT(!ct::is_lvalue_reference_qualified()); -CT_ASSERT(!ct::is_lvalue_reference_qualified(pmf_v{})); -CT_ASSERT(ct::is_lvalue_reference_qualified()); -CT_ASSERT(ct::is_lvalue_reference_qualified(pmf_vl{})); -CT_ASSERT(!ct::is_lvalue_reference_qualified()); -CT_ASSERT(!ct::is_lvalue_reference_qualified(pmf_vr{})); -CT_ASSERT(!ct::is_lvalue_reference_qualified()); -CT_ASSERT(!ct::is_lvalue_reference_qualified(pmf_cv{})); -CT_ASSERT(ct::is_lvalue_reference_qualified()); -CT_ASSERT(ct::is_lvalue_reference_qualified(pmf_cvl{})); -CT_ASSERT(!ct::is_lvalue_reference_qualified()); -CT_ASSERT(!ct::is_lvalue_reference_qualified(pmf_cvr{})); +CT_ASSERT(!ct::is_lvalue_qualified()); +CT_ASSERT(!ct::is_lvalue_qualified(pmf{})); +CT_ASSERT(ct::is_lvalue_qualified()); +CT_ASSERT(ct::is_lvalue_qualified(pmf_l{})); +CT_ASSERT(!ct::is_lvalue_qualified()); +CT_ASSERT(!ct::is_lvalue_qualified(pmf_r{})); +CT_ASSERT(!ct::is_lvalue_qualified()); +CT_ASSERT(!ct::is_lvalue_qualified(pmf_c{})); +CT_ASSERT(ct::is_lvalue_qualified()); +CT_ASSERT(ct::is_lvalue_qualified(pmf_cl{})); +CT_ASSERT(!ct::is_lvalue_qualified()); +CT_ASSERT(!ct::is_lvalue_qualified(pmf_cr{})); +CT_ASSERT(!ct::is_lvalue_qualified()); +CT_ASSERT(!ct::is_lvalue_qualified(pmf_v{})); +CT_ASSERT(ct::is_lvalue_qualified()); +CT_ASSERT(ct::is_lvalue_qualified(pmf_vl{})); +CT_ASSERT(!ct::is_lvalue_qualified()); +CT_ASSERT(!ct::is_lvalue_qualified(pmf_vr{})); +CT_ASSERT(!ct::is_lvalue_qualified()); +CT_ASSERT(!ct::is_lvalue_qualified(pmf_cv{})); +CT_ASSERT(ct::is_lvalue_qualified()); +CT_ASSERT(ct::is_lvalue_qualified(pmf_cvl{})); +CT_ASSERT(!ct::is_lvalue_qualified()); +CT_ASSERT(!ct::is_lvalue_qualified(pmf_cvr{})); -CT_ASSERT(!ct::is_rvalue_reference_qualified()); -CT_ASSERT(!ct::is_rvalue_reference_qualified(pmf{})); -CT_ASSERT(!ct::is_rvalue_reference_qualified()); -CT_ASSERT(!ct::is_rvalue_reference_qualified(pmf_l{})); -CT_ASSERT(ct::is_rvalue_reference_qualified()); -CT_ASSERT(ct::is_rvalue_reference_qualified(pmf_r{})); -CT_ASSERT(!ct::is_rvalue_reference_qualified()); -CT_ASSERT(!ct::is_rvalue_reference_qualified(pmf_c{})); -CT_ASSERT(!ct::is_rvalue_reference_qualified()); -CT_ASSERT(!ct::is_rvalue_reference_qualified(pmf_cl{})); -CT_ASSERT(ct::is_rvalue_reference_qualified()); -CT_ASSERT(ct::is_rvalue_reference_qualified(pmf_cr{})); -CT_ASSERT(!ct::is_rvalue_reference_qualified()); -CT_ASSERT(!ct::is_rvalue_reference_qualified(pmf_v{})); -CT_ASSERT(!ct::is_rvalue_reference_qualified()); -CT_ASSERT(!ct::is_rvalue_reference_qualified(pmf_vl{})); -CT_ASSERT(ct::is_rvalue_reference_qualified()); -CT_ASSERT(ct::is_rvalue_reference_qualified(pmf_vr{})); -CT_ASSERT(!ct::is_rvalue_reference_qualified()); -CT_ASSERT(!ct::is_rvalue_reference_qualified(pmf_cv{})); -CT_ASSERT(!ct::is_rvalue_reference_qualified()); -CT_ASSERT(!ct::is_rvalue_reference_qualified(pmf_cvl{})); -CT_ASSERT(ct::is_rvalue_reference_qualified()); -CT_ASSERT(ct::is_rvalue_reference_qualified(pmf_cvr{})); +CT_ASSERT(!ct::is_rvalue_qualified()); +CT_ASSERT(!ct::is_rvalue_qualified(pmf{})); +CT_ASSERT(!ct::is_rvalue_qualified()); +CT_ASSERT(!ct::is_rvalue_qualified(pmf_l{})); +CT_ASSERT(ct::is_rvalue_qualified()); +CT_ASSERT(ct::is_rvalue_qualified(pmf_r{})); +CT_ASSERT(!ct::is_rvalue_qualified()); +CT_ASSERT(!ct::is_rvalue_qualified(pmf_c{})); +CT_ASSERT(!ct::is_rvalue_qualified()); +CT_ASSERT(!ct::is_rvalue_qualified(pmf_cl{})); +CT_ASSERT(ct::is_rvalue_qualified()); +CT_ASSERT(ct::is_rvalue_qualified(pmf_cr{})); +CT_ASSERT(!ct::is_rvalue_qualified()); +CT_ASSERT(!ct::is_rvalue_qualified(pmf_v{})); +CT_ASSERT(!ct::is_rvalue_qualified()); +CT_ASSERT(!ct::is_rvalue_qualified(pmf_vl{})); +CT_ASSERT(ct::is_rvalue_qualified()); +CT_ASSERT(ct::is_rvalue_qualified(pmf_vr{})); +CT_ASSERT(!ct::is_rvalue_qualified()); +CT_ASSERT(!ct::is_rvalue_qualified(pmf_cv{})); +CT_ASSERT(!ct::is_rvalue_qualified()); +CT_ASSERT(!ct::is_rvalue_qualified(pmf_cvl{})); +CT_ASSERT(ct::is_rvalue_qualified()); +CT_ASSERT(ct::is_rvalue_qualified(pmf_cvr{})); int main() { return 0; }