Templated vec

Simen kjaeraas simen.kjaras at gmail.com
Sat Sep 25 07:59:10 PDT 2010


bearophile <bearophileHUGS at lycos.com> wrote:

> Can you show me how to fix the second program?

This is issue #3467 - Non-int integral template parameters not correctly  
propagated

The solution is to use int instead of size_t:

struct Vec(int N) {
     void opBinary(string op:"~", int M)(Vec!M) {}
}
void main() {
     Vec!2 a1;
     Vec!3 a2;
     a1 ~ a2; // line 7, Error
}

-- 
Simen


More information about the Digitalmars-d-learn mailing list