const_cast operator

   
const_cast operator Cast to modify qualifiers

  postfix-expr  := const_cast <  type-id  > (  expression  ) 

The const_cast operator performs a type cast that can add or remove const and volatile qualifiers. No other modifications to the type are permitted.

If you cast away a const or volatile qualifier from an object, and then modify the object, the behavior is undefined.

Example

 template<typename T> T& unsafe(const T& x) {   return  const_cast  <T&>(x); } 

See Also

const , dynamic_cast , expression , reinterpret_cast , static_cast , type , volatile , Chapter 3

   


C++ in a Nutshell
C++ in a Nutshell
ISBN: 059600298X
EAN: 2147483647
Year: 2005
Pages: 270
Authors: Ray Lischner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net