-=> 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)
|