Possible way to achieve lazy loading with const objects

Steven Schveighoffer schveiguy at yahoo.com
Wed Sep 28 09:00:39 PDT 2011


On Wed, 28 Sep 2011 11:55:01 -0400, Kagamin <spam at here.lot> wrote:

> Steven Schveighoffer Wrote:
>
>> Trivial, and also undefined behavior ;)
>
> Well, it gets job done. If you don't like it, don't use logical const.

It's not a matter of whether I don't like it or not.  Undefined behavior  
means anything can happen.  The application could crash.  Memory could  
become corrupted.

I feel like in this area, labelling this as "undefined behavior" is an  
extreme.  I think with the right implementation (and the right  
preconditions), it should be possible to safely cast away const and modify  
the data.

I think it's worth trying to do.  All I was saying is, the language is not  
going to help you out on that.

-Steve


More information about the Digitalmars-d mailing list