Can't use variadic arguments to functions that use templates

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Tue Jul 23 09:15:01 PDT 2013


On Tuesday, 23 July 2013 at 14:03:01 UTC, JS wrote:
> I don't think you understand(or I've already got confused)...
>
> I'm trying to use B has a mixin(I don't think I made this 
> clear). I can't use it as a normal function. e.g., I can't seem 
> to do mixin(B(t)). If I could, this would definitely solve my 
> problem.

I'll stick with the reduced example, maybe you can apply it to 
the real world:

    template B(T...) {
       string B(T b) {
          string s;
          foreach(i, Type; T)
             s ~= Type.stringof ~ " " ~ b[i] ~ ";\n";
          return s;
       }
    }

    void main() {
       enum forced = B("x", "a", "b");
       pragma(msg, forced);
       mixin(forced);
    }


More information about the Digitalmars-d-learn mailing list