Fully transitive const is not necessary

Steven Schveighoffer schveiguy at yahoo.com
Thu Apr 3 13:27:52 PDT 2008


"Janice Caron" wrote
> On 03/04/2008, Steven Schveighoffer wrote:
>> Mean exactly what it says, that there is a piece of data stored with the
>>  class that is always mutable (to get nitpicky, I don't like the keyword
>>  mutable, as it implies that everything reachable through m is mutable, 
>> which
>>  it may not be).  I'm asking for the compiler to treat it as not part of 
>> the
>>  object state, *as if* it were a variable outside the class, in terms of
>>  const.  Think of it as an extra argument to all member functions that is 
>> not
>>  colored with the constancy of the member function.
>
> Perhaps there is a better solution. Perhaps, we could annotate
> functions which computationally expensive.
>
>    class SuperIntensiveCalculator
>    {
>       int f(int x) const expensive
>       {
>            /* do really intense calculation */
>       }
>    }
>
> I like that more. We simply give the compiler a hint that it might be
> worth caching the result.

This might solve this particular problem, but there are other reasons to 
have logical const types that are not solved this way.

-Steve 





More information about the Digitalmars-d mailing list