How to instantiate a template struct with a template constructor without relying on auto deduction?

ParticlePeter ParticlePeter at gmx.de
Wed Feb 21 14:11:10 UTC 2018


struct Foo(T) {
   T bar;
   this(S)(S s) {
     bar = convert(s);
   }
}

auto foo = Foo!int(some_float);


this works because S is deduced as typeof(some_float), but how 
would I instantiate the struct without relying on auto deduction?

Suppose we would have this kind of constructor where auto 
deduction is not possible:

   this(int n)(float f) {
     static foreach( i; 0..n) { do_some_ctfe_magic;}
   }

How to instantiate Foo then?


More information about the Digitalmars-d-learn mailing list