Why is my structure template does not compile?

BCS ao at pathlink.com
Thu Dec 11 15:47:42 PST 2008


Reply to Denis,

> On Fri, 12 Dec 2008 02:21:11 +0300, BCS <ao at 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 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).
> 

Oh, fud. I did get that wrong. I still think it's wrong as I'm not sure anything 
has 0 sizeof and even then that should be static assert.




More information about the Digitalmars-d-learn mailing list