TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: BALOG PAL
from: DARIN MCBRIDE
date: 1997-07-25 18:36:00
subject: mutable

 -=> Quoting Balog Pal to Jerry Coffin
 BP> I once ran into that problem: I had a list class that could be
 BP> accessed like an array, with simple integral index and [] operator. It
 BP> had a private member that stored the last accessed index and its
 BP> pointer, so traversing the list in sequential, upward direction was
 BP> fast as a real array. But that retrieval operator could not be made
 BP> const, as one could expect, and you could not pass a constant (by
 BP> value) list here and there because of that internal mechanism.
Try casting away const to the this pointer... ;-)
List* nonconst_this = (List*)this;
It's dirty, but it worked.  (Not anymore - mutable relieves us of the need,
and you'd have to use const_cast() now!)
 BP> So that mutable proposal can really help. The only problem is that
 BP> it's not yet supported in compilers.  Or did anyone see it implemented?
GCC 2.7.2.x has it (or at least 2.7.2.1 does).  Watcom 11 purports to have
it.  I imagine MSVC 5 does.  Borland 5 might, but I doubt it.
... Danger, Balog Pal!  Off-topic messages!  Danger!
--- FastEcho 1.46
---------------
* Origin: House of Fire BBS - Toronto - (416)601-0085 - v.34 (1:250/536)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.