Casting away const

Simen kjaeraas simen.kjaras at gmail.com
Mon Aug 9 12:49:12 PDT 2010


Simen kjaeraas <simen.kjaras at gmail.com> wrote:

> Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>
>> Note also that the optimization you stated is not possible, even  
>> without casting away const, but would be possible on an immutable  
>> class.  But the fact that the compiler cannot peek into the  
>> implementation of the opAssign means it's forced to make no assumptions  
>> about the result of opAssign
>
> You're right, I was thinking of immutable.

This said, one of the reasons casting away const is undefined, is because
the underlying type may be immutable.

-- 
Simen


More information about the Digitalmars-d-learn mailing list