From d79b7da0679eb8bbd1489ac89de389a069cbb820 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 8 Sep 2017 14:19:46 +1000 Subject: [PATCH] types/traits: make func_traits more robust --- types/traits.hpp | 68 +++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/types/traits.hpp b/types/traits.hpp index 738522a6..b15af3c7 100644 --- a/types/traits.hpp +++ b/types/traits.hpp @@ -209,31 +209,51 @@ struct remove_member_const { /// if the type is invokable the alias `return_type' will be defined for the /// return type, and the alias tuple `argument_types' will be defined for the /// arguments; +namespace detail { + template + struct func_traits { }; + + + //------------------------------------------------------------------------- + template + struct func_traits { + using return_type = ResultT; + using argument_types = std::tuple; + }; + + + //------------------------------------------------------------------------- + template + struct func_traits { + using return_type = ResultT; + using argument_types = std::tuple; + }; + + + //------------------------------------------------------------------------- + template + struct func_traits { + using return_type = ResultT; + using argument_types = std::tuple; + }; +}; + + +//----------------------------------------------------------------------------- template -struct func_traits : public func_traits> { }; - - -//----------------------------------------------------------------------------- -template -struct func_traits { - using return_type = ResultT; - using argument_types = std::tuple; -}; - - -//----------------------------------------------------------------------------- -template -struct func_traits { - using return_type = ResultT; - using argument_types = std::tuple; -}; - - -//----------------------------------------------------------------------------- -template -struct func_traits { - using return_type = ResultT; - using argument_types = std::tuple; +struct func_traits : public ::detail::func_traits< + // we apply as many transforms as possible before palming it off to the + // detail class so that we don't have to write as many distinct cases. + ::util::chain_t +> { + // we may as well record the underlying type here. it might prove useful + // to someone. + using type = T; };