opDispatch forwarding and ifti

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 27 04:14:10 PST 2017


Has anyone ever found a way to actually implement forwarding 
properly with opDispatch, such that it works for both general 
templates and also functions called using ifti (implicit function 
template instantiation)?

I've spent a day on it trying to improve std.typecons.Proxy to 
support this and it seems impossible.

The problem is to support this:

template X()
{
     alias X = int;
}

struct S0
{
     template A(T ...)
     {
         alias A = X;
     }

     template foo(T ...)
     {
         void foo(K)(K t) {}
     }
}

struct S1
{
     private S0 _s0;
     import std.typecons : Proxy;
     mixin Proxy!_s0;
}

unittest
{
     S1 s1;

     alias B0 = s1._s0.A!();
     static assert(is(B0!() == int));
     s1._s0.foo(3);

     alias B1 = s1.A!();
     static assert(is(B1!() == int));
     s1.foo(3);
}


More information about the Digitalmars-d mailing list