From dfea57fd02de60e24b9f6adb41325438fe0b6192 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 19 Mar 2017 00:27:59 +0100 Subject: [PATCH] Function-Tools: switch tail-call to variadic template ..otherwise unchanged. NOTE: we need two variants, since lambdas are always const functions, while a member pointer to (non)const function would not be captured by that overload and thus recurse into the main case and fail there with "has no operator()" --- research/try.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/research/try.cpp b/research/try.cpp index b65508ba2..9f582d6c7 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -64,34 +64,22 @@ namespace lib { namespace meta { template< typename RET, class CLASS - , typename A1 + , typename...ARGS > - struct _Fun + struct _Fun { typedef RET Ret; - typedef Types Args; - typedef RET Sig(CLASS* const, A1); + typedef Types Args; + typedef RET Sig(CLASS* const, ARGS...); }; - template< typename RET, class CLASS - , typename A1 + , typename...ARGS > - struct _Fun + struct _Fun { typedef RET Ret; - typedef Types Args; - typedef RET Sig(CLASS* const, A1); - }; - - template< typename RET, class CLASS - , typename A1 - , typename A2 - > - struct _Fun - { - typedef RET Ret; - typedef Types Args; - typedef RET Sig(CLASS* const, A1,A2); + typedef Types Args; + typedef RET Sig(CLASS* const, ARGS...); }; }}//namespace lib::meta @@ -170,12 +158,15 @@ main (int, char**) auto lambda = [&](uint ii) { return funk.fun(ii); }; + Fun f7{lambda}; + showType (funny); showType (&funny); showType (Funky::notfunny); showType (memfunP); showType (lambda); + showType (f7); cout << "\n\n-------\n";