|
Boost : |
From: Darin Adler (darin_at_[hidden])
Date: 2002-08-27 11:23:17
On Tuesday, August 27, 2002, at 07:55 AM, Fernando Cacciola wrote:
> This is why I chosen to use const_cast<> instead.
Sadly, const_cast in this case leads to undefined behavior. You can't
just const_cast to turn an object that was defined as const into
non-const. You can only use it to strip off const that was added.
So const_cast is not as powerful as mutable. And although you have a
problem with mutable in this case, using const_cast instead is not the
solution.
In practice, this arises because C++ implementations are allowed to put
entirely const objects in read-only areas of memory. The program must
be told about the mutable member so the implementation knows that it
might be modified.
-- Darin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk