[Next] [Prev] [Up] [Top]

14.0 Type Conversions

NON_CONST (R)


If the compiler supports it, always use reinterpret_cast<> in preference to any other mechanism. Use the mutable keyword if the compiler supports it and this is a "cache" kind of usage.

For Unix, in rare cases, particularly when updating a "cache" for a conceptually const object, clients will need to "cast away const". Since this is not available in C++, use the macro NON_CONST in place of "this".

Note that when compilers begin support the "mutable" keyword, this mechanism will be obsolete.

Example:

((X*) this)->updateCache(); // bad

NON_CONST->updateCache(); // better

With the mutable keyword, the updateCache() method could be declared a const method.


No Title
[Next] [Prev] [Up] [Top]

Generated with CERN WebMaker

This site was grabbed using the TRIAL version of Grab-a-Site. This message does not appear on a licensed copy of Grab-a-Site.