Cannot use function as foreach aggregate.
Lutger
lutger.blijdestijn at gmail.com
Wed Apr 4 09:58:09 PDT 2007
BCS wrote:
> I can't help but wonder if this works.
>
> template ToDelegate(RetType, RetType function(Args) func, Args...)
> {
> struct S
> {
> static S s
> RetType callMe(Args args)
> {
> return func(args);
> }
> }
> alias &S.s.callMe ToDelegate;
> }
Perhaps it could be simplified to this:
ReturnType!(typeof(func)) delegate (A)
toDelegate(alias func, A = ParameterTypeTuple!(typeof(func)) )()
{
return ( A args) { return func(args); } ;
}
But it seems there is a bug with type tuples in delegate literals, which
also affects your example. This can be made to work though with string
mixins, expanding the tuples to a parameter list.
More information about the Digitalmars-d
mailing list