diff --git a/research/try.cpp b/research/try.cpp index 5c87d4b1e..d8bc331b4 100644 --- a/research/try.cpp +++ b/research/try.cpp @@ -51,7 +51,6 @@ typedef unsigned int uint; #include #include -using lib::meta::_Fun; using std::function; using std::placeholders::_1; @@ -62,21 +61,50 @@ using std::tuple; ////////////////############# Investigation of implementation variants namespace lib { namespace meta { - - template - struct _Fun + + template + struct _FuZ + : _FuZ + { }; + + /** Specialisation for a bare function signature */ + template + struct _FuZ { using Ret = RET; using Args = Types; using Sig = RET(ARGS...); }; + /** Specialisation for using a function pointer */ + template + struct _FuZ + : _FuZ + { }; + /** Specialisation when using a function reference */ + template + struct _FuZ + : _FuZ + { }; + + /** Specialisation to deal with member pointer to function */ template - struct _Fun - : _Fun + struct _FuZ + : _FuZ + { }; + + /** Specialisation to handle member pointer to const function; + * indirectly this specialisation also handles lambdas, + * as redirected by the main template (via `decltype`) */ + template + struct _FuZ + : _FuZ { }; }}//namespace lib::meta + +using lib::meta::_FuZ; + ////////////////############# Investigation of implementation variants @@ -123,7 +151,7 @@ template void showType (F) { - using Sig = typename _Fun::Sig; + using Sig = typename _FuZ::Sig; SHOW_TYPE (F); SHOW_TYPE (Sig); @@ -167,6 +195,8 @@ main (int, char**) SHOW_TYPE (decltype(&Funky::operator())); SHOW_TYPE (decltype(lambda)); + SHOW_TYPE (_FuZ::Sig); + cout << "\n.gulp.\n"; return 0;