[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppConstCast
You should avoid casting away const, except when using a non-const-correct API [1].
Don't use C-style casts [2].
Other casts are:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppConstCast
(C++) const_cast
Keyword to enable you to cast away a constness of a variable.You should avoid casting away const, except when using a non-const-correct API [1].
Don't use C-style casts [2].
Other casts are:
- static_cast, for casting between simple data types (e.g. between int and double)
- dynamic_cast, for casting between related classes
- reinterpret_cast, for casting between unrelated data types
Reference
- 1) Herb Sutter and Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Chapter 94: 'Avoid casting away const'
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
