Hey again.
I'm still working on my functor class, and now it works with method
functions too; you pass it the method function, as well as the object
you want to be 'this' when the method is called, for example:
struct Shill
{ void Conforming(string, int); }
Shill myShill;
functor<void (string,int)> theFunctor;
theFunctor = MethodWrap(&myShill, &Shill::Conforming);
theFunctor("Seven", 11);
MethodWrap is a namespace-level template function that gleans the
'Shill' type from the parameters you pass to it -- no need for a
separate function for everything!
My question is this. I would very much like to skip all that ugly
syntax in the method pointer usage, and pare it down to something
smooth like this:
theFunctor = myShill.Wrap(Conforming);
That resonates much better with me because
* it looks like the assignment it is
* the 'target' instance is naturally part of the syntax
* it doesn't need you to pass in the &Shill:: which should be
unnecessary since it must always match the 'target' anyway.
But about #3, C++'s syntax reader doesn't seem to have any idea what
Conforming is unless you pass &Shill:: in. So I'm trying to do it with
one of these Macros:
#define WrapShill(t, f) FunctionWrap(&t, &Shill::f)
theFunctor = WrapShill(&myShill, Conforming);
or
#define WrapShill(f) Wrap(&Shill:f)
theFunctor = myShill.WrapShill(Conforming);
But they're both full of redundancy thus ugly. Does anyone have an
alternate solution to get rid of the redundancy? I know this is kind of
petty but smoothing out syntax is my hobby right now.
Dan