
Boost : 
Subject: Re: [boost] Discovering C++11 lambda argument and result types to construct boost::function
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 20120213 16:47:46
On Mon, Feb 13, 2012 at 11:08 AM, Frank Birbacher <bloodymir.crap_at_[hidden]>wrote:
> BEGIN PGP SIGNED MESSAGE
> Hash: SHA1
>
> Hi!
>
> Am 12.02.12 17:37, schrieb Mathias Gaunard:
> > And that metafunction 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_typetraits/reference/remove_pointer.html
> )
>
> So this is the point: I need a signature from a member function. There
> is no type trait that does this. Any other suggestions?
>
[...]
Boost.FunctionTypes + Boost.MPL?
Something like
typename boost::function_types::function_type<
typename boost::mpl::push_front<
typename boost::function_types::result_type<F>::type,
typename boost::mpl::pop_front<
typename boost::function_types::parameter_types<F>::type
>::type
>::type
>::type
or define a metafunction that converts a pointertomemberfunction type to
the desired function type for some spectrum of arities:
template< class F > struct member_function_to_function;
template< class R, class T > struct member_function_to_function< R (T::*)()
> { typedef R type(); };
template< class R, class T > struct member_function_to_function< R (T::*)()
const > { typedef R type(); };
// etc...up to some maximum arity
 Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk