I am trying to simplify (through make_fn()) the creation of functors that pre-process parameters (through wrap()) for arity n member functions.
The generation of functors basically works, but so far only by explicitly specifying parameter types for a member function.
Now I would like to generate the correct functor from the type of the member function that it controls:
struct X {};
template<class C, typename T1, bool (C::*F)(T1)>
inline
bool wrap(C* c, X x)
{
return (c->*F)(process<T1>(x));
}
template<class C, typename T1, bool (C::*F)(T1)>
inline
boost::function<bool (C*, X)> make_fn(F f)
{
return boost::bind(&wrap<C, T1, F>, _1, _2);
}
With this, however, vC ++ and g ++ are not seen Fas a type for a parameter make_fn(). I have to skip something obvious here and feel a little blind.
The idea was that it should work as follows:
struct A
{
bool f1(bool) { return true; }
};
void test()
{
A a;
X x;
make_fn(&A::f1)(&a, x);
}
Any ideas on how to make this work?
:
, :
bool invoke(C* c, const char* const functionName, int argCount, X* args);
X - , (int, std::string,...).
, - .
, , throw. , .
, -.