Why is my structure template does not compile?

2008-12-11 Thread Weed
struct S( Element ) { Element[] data; this( in uint len ) { data.length = len; } ref Element opIndex( in uint n ) { return data[n]; } ref Element opIndexAssign( in Element a, in uint n ) { data[n] += a; return data[n]; }

Re: Why is my structure template does not compile?

2008-12-11 Thread Denis Koroskin
On Fri, 12 Dec 2008 02:21:11 +0300, BCS a...@pathlink.com 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

Re: Why is my structure template does not compile?

2008-12-11 Thread Weed
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

Re: Why is my structure template does not compile?

2008-12-11 Thread BCS
Reply to Denis, On Fri, 12 Dec 2008 02:21:11 +0300, BCS a...@pathlink.com wrote: Reply to Weed, 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

Re: Why is my structure template does not compile?

2008-12-11 Thread Denis Koroskin
On Fri, 12 Dec 2008 02:47:42 +0300, BCS a...@pathlink.com wrote: Reply to Denis, On Fri, 12 Dec 2008 02:21:11 +0300, BCS a...@pathlink.com wrote: Reply to Weed, invariant() { // If I comment out next line compilation goes smoothly: assert( Element.sizeof 0 ); } OTOH that assert is