TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  CON#001Checked automatically with code checker

Synopsis:Make unsafe type conversions explicit rather than implicit
Language:C++
Severity Level:2
Category:Conversions


Description:
If casting is required, make it explicit and use the following C++ cast operators:
  • const_cast: to remove the const, volatile, and __unaligned attributes.
  • dynamic_cast: for conversion of polymorphic types, where class hierachy navigation is unavoidable.
  • static_cast: for conversion of nonpolymorphic types.

    This rule does not only apply to casting: it also applies to unsafe conversions by means of constructors, conversion operators, and conversion functions. See further [INT#001], [INT#017], [POR#022].



  • Literature References:
    Ellemtel Rule 44
    ISC++ Rec. 6.1.