Difference between revisions of "Cpp Coding Standards/TYPE"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Cpp Coding Standards/Topics/TYPE moved to Cpp Coding Standards/Type Safety: Improve Cpp_Coding_Standards structure.)
Line 1: Line 1:
== Type Safety ==
+
Topic-Id: TYPE
Casts and type recognition
+
 
 +
Casts and type recognition.
 +
 
 
----
 
----
 
=== Summary ===
 
=== Summary ===
==== TypesNotRepresentations ====
+
==== Types, not Representations <span id="NoRepr">(NoRepr)</span> ====
 
Rely on types, not on representations. Don't think in bits, don't memcpy non-PODs.
 
Rely on types, not on representations. Don't think in bits, don't memcpy non-PODs.
  
==== NoCStyleCasts ====
+
[[/NoRepr|Details]]
 +
 
 +
==== No C-Style Casts <span id="CCast">(CCast)</span> ====
 
Don't use C-Style casts, but the C++ casts.
 
Don't use C-Style casts, but the C++ casts.
  
==== AvoidPtrStaticCasts ====
+
[[/CCast|Details]]
 +
 
 +
==== Avoid static_cast on Pointers <span id="StacaPtr">(StacaPtr)</span> ====
 
Use dynamic_cast instead of  static_cast when treating pointers polymorphically.
 
Use dynamic_cast instead of  static_cast when treating pointers polymorphically.
  
==== NoTypeSwitching ====
+
[[/StacaPtr|Details]]
 +
 
 +
==== No switch on Types <span id="NoSwitch">(NoSwitch)</span> ====
 
Don't use switch, when the cases represent types. Prefer polymorphism.
 
Don't use switch, when the cases represent types. Prefer polymorphism.
 +
 +
[[/NoSwitch|Details]]
  
 
----
 
----
 
=== Related Rules ===
 
=== Related Rules ===
* [[../CLSDESIGN#NoImplicitConversions | CLSDESIGN:NoImplicitConversions]]
+
* [[../Class Design#NoConv |CLSDESIGN:NoConv]] - No Implicit Conversions
----
+
=== Explanations ===
+
  
 
----
 
----
 
[[Category:Coding Standards]]
 
[[Category:Coding Standards]]

Revision as of 17:24, 29 November 2006

Topic-Id: TYPE

Casts and type recognition.


Summary

Types, not Representations (NoRepr)

Rely on types, not on representations. Don't think in bits, don't memcpy non-PODs.

Details

No C-Style Casts (CCast)

Don't use C-Style casts, but the C++ casts.

Details

Avoid static_cast on Pointers (StacaPtr)

Use dynamic_cast instead of static_cast when treating pointers polymorphically.

Details

No switch on Types (NoSwitch)

Don't use switch, when the cases represent types. Prefer polymorphism.

Details


Related Rules


Personal tools