Fully transitive const is not necessary

Janice Caron caron800 at googlemail.com
Thu Apr 3 13:20:05 PDT 2008


On 03/04/2008, Steven Schveighoffer <schveiguy at yahoo.com> 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.



More information about the Digitalmars-d mailing list