Functors

BCS ao at pathlink.com
Thu Jun 28 11:55:06 PDT 2007


Reply to Craig,

> Functors are more flexible than delegates because they
> can be associated with static/global functions as well as functions
> local to a class or struct.

if all you want to do is convert fn ptrs to delegates this works:

|T delegate(A) Fn2Dg(T, A...)(T function(A) f)
|{
|	struct tmp
|	{
|		T ret(A args){ return (cast(T function(A))this)(args); }
|	};
|	return &(cast(tmp*)f).ret;
|}





More information about the Digitalmars-d mailing list