Why D const is annoying
Mehrdad
wfunction at hotmail.com
Sat Dec 10 20:27:31 PST 2011
Another bug, this time regarding invariant()....
(I think this is related to the previous one about int vs. size_t in
template parameters, but I'm not sure...)
template NArray(T, size_t N)
{ static if (N > 0) { alias NArray!(T, N - 1)[] NArray; } else {
alias T NArray; } }
struct Tensor(T, Length...)
{
enum N = Length[0];
invariant() { }
this(scope NArray!(T, N) copyOfItems...) { }
@property T[] data() { return null; }
Tensor!(typeof(mixin("data[0] " ~ op ~ " data[0]")), N)
opBinary(string op)(Tensor other)
{ return typeof(return).init; }
}
void main()
{
Tensor!(size_t, 1) a;
a = a + a;
}
Error: this for __invariant needs to be type Tensor not type Tensor!(uint,1)
More information about the Digitalmars-d
mailing list