[function/bind] function object type introspection

Hi, I've got couple questions. Might be someone can point me in right direction. Let's say I've got this class ConcreteFunctor which should handle all kinds of functions. I want to store the function as boost::function object, thus the class has template parameter - FunctionType: template<typename FuncType> ConcreteFunctor : public AbstractFunctor { ConcreteFunctor( FuncType f ) ... {} virtual invoke( std::vector

Hi!
please see my partial suggestion below...
On Thu, Oct 1, 2009 at 11:02 AM, Gennadiy Rozental
Hi,
.... Now I need to implement object maker
template<typename F> boost::shared_ptr<AnstractFunctor> make_functor( F f ) { typedef boost::function<???> TypeName; return boost::shared_ptr<AbstrctFunctor>( new ConcreteFunctor<FuncType>( f ) ); }
I was able to work fine with free functions by just removing pointer from F. Now to the questions:
1. How do I deduce boost::function type from pointer to member functions:
Essentially if F is R (A::*)(T1,T2) I need to get boost::function
...
Is may be Boost.FunctionTypes what you are looking for? http://www.boost.org/doc/libs/1_40_0/libs/function_types/doc/html/boost_func... Regards, Ovanes

Ovanes Markarian wrote:
Essentially if F is R (A::*)(T1,T2) I need to get boost::function
Is may be Boost.FunctionTypes what you are looking for? http://www.boost.org/doc/libs/1_40_0/libs/function_types/doc/html/boost_func...
It looks like right area, but i can't see how would I apply these. function_type expects mpl sequense. Gennadiy

function_type expects mpl sequense.
As far as I understand it, you need to apply result_type to your F and
parameter_types to F. From there you can model your function. Or am I wrong? template<class F> some_return_type make_function(F f) { typedef typename result_type<F>::type result_type; typedef typename parameter_types<F>::type mpl_seq_params; //insert the result type to the mpl_seq_params => fct_sig; ... } But I am not sure if it works, this is my assumption only. Regards, Ovanes

BTW, you can use enable if and is_function_pointer to allow passing function
pointers only. In case with the function objects you need to implement other
inspection strategies.
On Thu, Oct 1, 2009 at 2:10 PM, Ovanes Markarian
function_type expects mpl sequense.
As far as I understand it, you need to apply result_type to your F and parameter_types to F. From there you can model your function. Or am I wrong?
template<class F> some_return_type make_function(F f) { typedef typename result_type<F>::type result_type; typedef typename parameter_types<F>::type mpl_seq_params;
//insert the result type to the mpl_seq_params => fct_sig;
... }
But I am not sure if it works, this is my assumption only.
Regards, Ovanes

Is may be Boost.FunctionTypes what you are looking for? http://www.boost.org/doc/libs/1_40_0/libs/function_types/doc/html/boo...
It looks like right area, but i can't see how would I apply these.
function_type expects mpl sequense.
Maybe what you need is a combinatioin of FunctionTypes and TypeTraits
//example with type_traits/function_traits
#include
participants (3)
-
AlfC
-
Gennadiy Rozental
-
Ovanes Markarian