advanced function binding

Jason House jason.james.house at gmail.com
Thu Mar 29 19:43:24 PDT 2007


Wow, this sounds exactly like a set of C++ code that I plan to convert 
to D in the near future.  I look forward to seeing your final resolution 
to this problem.

Moritz Warning wrote:
> 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