unclear compile error for struct with string template

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 25 04:41:27 PDT 2014


Oleg B:

> [code]
> void doSome(size_t N, T, string AS)( vec!(N,T,AS) v ) { }
> struct vec(size_t N, T, string AS) { T[N] data; }
> void main() { doSome( vec!(3,float,"xyz")([1,2,3]) ); }
> [/code]
>
> compile with new dmd v2.066.0 and get error:
>
> Error: template opbin.doSome(ulong N, T, string AS)(vec!(N, T, 
> AS) v) specialization not allowed for deduced parameter AS
>
> what does it mean?

See also:


struct Vec(size_t N, T, alias string AS) {
     T[N] data;
}

void doSome(size_t N, T, alias string AS)(Vec!(N, T, AS) v) {}

void main() {
     auto v = Vec!(3, float, "xyz")([1, 2, 3]);
     doSome(v);
}


(Note that in D the names of types and structs start with an 
upper case).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list