On Fri, 12 Dec 2008 02:21:11 +0300, BCS <[email protected]> wrote:
Reply to Weed,ref Element opIndex( in uint n ) { return data[n]; }ref Element opIndexAssign( in Element a, in uint n ) { data[n] += a; return data[n]; }I'm guessing as I don't use 2.0 but I think that this is a bug. DMD is trying to say that the above returns are trying to return something that can't be referenced (like a math expression result).
It is a bug, indeed. The struct 'invariant' prevents proper template instantiation somehow... Removing it makes code work as intended. I'll submit a bug report.
invariant() { // If I comment out next line compilation goes smoothly: assert( Element.sizeof > 0 ); }OTOH that assert is wrong. Element.sizeof will always return 8, the size of an array reference. What you want is Element.length.
No, I don't think so. Don't confuse 'Element' with 'data'. Element is a type, it doesn't have a length property. But it does have sizeof (an example of Element is an 'int', which is 4 bytes long).
