
On Mon, 08 Oct 2007 07:39:22 +0200, Marco Costalba <mcostalba@gmail.com> wrote:
On 10/8/07, Joel de Guzman <joel@boost-consulting.com> wrote:
There's no way to detect the signature of a template function (the operator()):
Perhaps you don't need this. You only need to check if the template function operator() matches one signature in the Signatures set.
I have found this nice (and very small) code from Paul Mensonides that seems to works (at least for me)
http://www.mail-archive.com/boost@lists.boost.org/msg00164.html
The limitation is that you have to specify the type of the function, but in our case is not a problem because we have a finite set called 'Signatures' among which to choose the operator() type.
As you can see from his testing example:
truct X { void operator()(void) { return; } };
struct Y { };
struct Z { template<class T> T operator()(T v) const { return v; } };
int main(void) { std::cout << has_function_call<void (X::*)(void)>::value << '\n' << has_function_call<void (Y::*)(void)>::value << '\n' << has_function_call<int (Z::*)(int) const>::value << '\n'; return 0; }
It is possible to check against any operator() given that you now the signatures you are looking for. Now the challange is, given a function obect of class F, to forge a way to loop across Signatures, that are function signatures,
void (void) void (void) int (int) const
transform in the corresponding member signatures of class F
void (F::*)(void) void (F::*)(void) int (F::*)(int) const
And check each one with has_function_call() until a match is found or return an error otherwise.
Easier to say then to do ;-)
Marco
This is exactly how my second implementation works. :-) See my proposal: http://archives.free.net.ph/message/20071007.223315.b8f57ef5.en.html Regards, Marco -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/