
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! Am 12.02.12 17:37, schrieb Mathias Gaunard:
And that meta-function is just
template<class F> struct function_type : remove_pointer<decltype(&F::operator())> { };
Well, that does not work for the following reason (example code below): "The same type as T, but with any pointer modifier removed. Note that pointers to members are left unchanged: removing the pointer decoration would result in an invalid type." (see: http://www.boost.org/doc/libs/1_48_0/libs/type_traits/doc/html/boost_typetra... ) So this is the point: I need a signature from a member function. There is no type trait that does this. Any other suggestions? Frank //////////// EXAMPLE: #include <type_traits> #include <utility> #include <boost/function.hpp> using boost::function; template<typename F> struct function_type { typedef typename std::remove_pointer< decltype(&F::operator()) >::type signature; typedef function<signature> type; }; template<typename F> typename function_type<F>::type make_function(F && f) { typedef typename function_type<F>::type result_type; return result_type(std::forward<F>(f)); } int main() { auto a = make_function([](int){ return 4; }); } //////////// OUTPUT GCC 4.6: MainTest.cpp:26:45: error: invalid use of incomplete type 'function_type<main()::<lambda(int)> >::type {aka struct boost::function<int (main()::<lambda(int)>::*)(int)const> }' function_fwd.hpp:33:38: error: declaration of 'function_type<main()::<lambda(int)> >::type {aka struct boost::function<int (main()::<lambda(int)>::*)(int)const>}' MainTest.cpp:26:45: error: unable to deduce 'auto' from '<expression error>' -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: keyserver x-hkp://pool.sks-keyservers.net iEYEARECAAYFAk85X7IACgkQhAOUmAZhnmpyDQCfdZ8860I/iuZZ1UE2zP07Bfq8 xToAn0g0cwkxFYWNk+SRlTDIyr97MZup =4eow -----END PGP SIGNATURE-----