Boost logo

Boost Users :

From: Richard Damon (rdamon_at_[hidden])
Date: 2003-10-22 13:12:47


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Mark Sizer
> Sent: Wednesday, October 22, 2003 12:45 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] Re: [OT a bit] Condition variable and const-
> correctness
>
> Richard Damon wrote:
> Ooops. You are correct. I consider this a language bug. Take the
> following:
>

The issue is that the compiler will only enforce "Physical" constness as
this is all it knows. The compiler can not know if the object pointed to is
part of the objects logical state or not. This is also why we have mutable,
so we can let the compiler know that some parts can be changed without
effecting the "logical value" of the object.

Your sample is a little off. You call the following to code sequences
identical:

 _paMine->rkiValue()
and
 raMine().rkiValue()

there is a significant difference, the first just accesses the pointer
(which is const because you are in a const member function), the second
takes the const pointer and tries to put it through a non-const reference
before calling the const member function. You need to either use rkaMine()
to tell the compiler you don't want the non-const ref, or rename rkaMine()
to raMine() so you let the compilers overload resolution mechanisms
determine by context if you can get the non-const reference.

Richard Damon

-- 
rbrdamon_at_[hidden] (Home)
rdamon_at_[hidden] (Work)

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net