Simen kjaeraas:
> This is issue #3467 - Non-int integral template parameters not correctly
> propagated
> The solution is to use int instead of size_t:
Thank you! :-)
I'll add a template constraint to be sure M it's positive:
void opBinary(string op:"~", int M)(Vec!M) if (M >= 0) {}
Bye,
bearo
This version works, but it requires a hidden field with distinct name (and no
gensym at compile time is available). Do you know a better solution that avoids
the need for the distinct hidden field?
struct Vec(size_t N) {
enum size_t _hiddenVecLength = N;
void opBinary(string op:"~", T)(
bearophile 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
This is an array struct template, this code compiles:
struct Vec(size_t N) {
void opBinary(string op:"~", size_t M)(int[M]) {}
}
void main() {
Vec!2 a1;
int[3] a2;
a1 ~ a2; // OK
}
But this code doesn't compile:
struct Vec(size_t N) {
void opBinary(string op:"~", size_t M)(