const and mutable declarations in one union

Sergey Kovrov kovrov+digitalmars at gmail.com
Tue Jan 13 17:50:35 PST 2009


On 1/14/2009 3:18 AM, Daniel Keep wrote:
> Finally, if you have questions on how to do something, please direct
> them to the D.learn newsgroup in future.

Well, this was not exactly point of my question - how to do this. There 
are few "valid" ways - getters/setters (properties) is one of them, to 
have const pointers to mutable data is other, and perhaps there could be 
even more.

I just wanted to point if such usage of union is invalid, it will be 
nice to assert this in compile time or at least have note in specs.

Or rather I wanted to comment on using invariant and const in this 
context lead to same effect - immutable declaration, which is feels 
wrong. If I were used invariant - this would be exactly what I expect. 
But for const I hope to get readonly view of any data, be it immutable 
or not.


-- serg.



More information about the Digitalmars-d mailing list