From 0b7559ce9ae6b0ffd5cc8a011ef189c0be863026 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 19 Mar 2017 00:19:07 +0100 Subject: [PATCH] Function-Tools: include lambdas into the investigation ...and move the tail-call of the template instantiation into try.cpp This experiment clearly shows the discrepancy now: - binding a member pointer directly into a function object will expand the argument list - but binding a similar lambda into a function object won't (it is not necessary due to the context capture) The result is that we need to drop support for one of those cases, and it is clear that the member poiter will be the looser... --- research/try.cpp | 47 +++++++++++++++++++++++++++++++++++++++ src/lib/meta/function.hpp | 4 ++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/research/try.cpp b/research/try.cpp index a4b034715..b65508ba2 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -59,6 +59,46 @@ using std::bind; using std::string; using std::tuple; +////////////////############# Investigation of implementation variants +namespace lib { +namespace meta { + + template< typename RET, class CLASS + , typename A1 + > + struct _Fun + { + typedef RET Ret; + typedef Types Args; + typedef RET Sig(CLASS* const, A1); + }; + + template< typename RET, class CLASS + , typename A1 + > + 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); + }; + +}}//namespace lib::meta +////////////////############# Investigation of implementation variants + + + int funny (uint i) { @@ -128,12 +168,19 @@ main (int, char**) Fun f6{bind (f5, funk, _1)}; + auto lambda = [&](uint ii) { return funk.fun(ii); }; showType (funny); showType (&funny); showType (Funky::notfunny); showType (memfunP); + showType (lambda); + + cout << "\n\n-------\n"; + + SHOW_TYPE (decltype(&Funky::operator())); + SHOW_TYPE (decltype(lambda)); cout << "\n.gulp.\n"; diff --git a/src/lib/meta/function.hpp b/src/lib/meta/function.hpp index e6b43e2a3..34d831dfd 100644 --- a/src/lib/meta/function.hpp +++ b/src/lib/meta/function.hpp @@ -262,7 +262,7 @@ namespace meta{ }; /** Specialisations for member function pointers */ - template +/* template struct _Fun { typedef RET Ret; @@ -376,7 +376,7 @@ namespace meta{ typedef Types Args; typedef RET Sig(CLASS* const, A1,A2,A3,A4,A5,A6,A7,A8); }; - +*/ template