advanced function binding
Moritz Warning
mwarning at web.de
Tue Mar 27 22:41:29 PDT 2007
Hi,
I try to write a RPC interface in D and have problems
to start. I've already written the code in C++, but it became
quite unmanageable and ugly because I
had to write various workarounds.
The core problem is to hide an arbitrary (member) function pointer
in a class. The argument values are provided _later_ in
the form of a char[][] to a class function:
void setArgs(char[][] args)
The wrapped function is called later by a class function that should rely on two template parameters only; the type of object the function will be called on, and the return type:
R call(R,T)(T obj) { /**/ }
For the type conversion I have several global T convert(T)(char[]) functions.
I've read about std.bind and recursive templates but wasn't able to
make much use of them.
I have thought about to pass a lazy template delegate (with convert(T)(char[]) inside)
to std.bind, but that's apparently not possible
Maybe somebody can give me a push into the right direction. :-)
.
More information about the Digitalmars-d-learn
mailing list