summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2011-12-31 00:15:06 -0200
committerQt by Nokia <qt-info@nokia.com>2012-03-24 19:07:22 +0100
commitad81f75429f6c5586d667880f90f4a425f1ce968 (patch)
tree543600f4a8d20c8be210a0008cc5ab4dd4116148 /doc
parent4131c323a36ee8680a3b4d66a2a03a00544751c2 (diff)
Add macros for assuming and unreachable code
Use these macros to tell the compiler about conditions that may happen, so it will generate better code. But do not assume that they will do anything special. Change-Id: I89ec4f65f48a9340ccf5ffc4ae4b8c3d8897c8b1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/src/snippets/code/src_corelib_global_qglobal.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/src/snippets/code/src_corelib_global_qglobal.cpp b/doc/src/snippets/code/src_corelib_global_qglobal.cpp
index 21bea7aef8..16f6783a52 100644
--- a/doc/src/snippets/code/src_corelib_global_qglobal.cpp
+++ b/doc/src/snippets/code/src_corelib_global_qglobal.cpp
@@ -560,3 +560,26 @@ bool readConfiguration(const QFile &file)
return true;
}
//! [qunlikely]
+
+//! [qunreachable-enum]
+ enum Shapes {
+ Rectangle,
+ Triangle,
+ Circle,
+ NumShapes
+ };
+//! [qunreachable-enum]
+
+//! [qunreachable-switch]
+ switch (shape) {
+ case Rectangle:
+ return rectangle();
+ case Triangle:
+ return triangle();
+ case Circle:
+ return circle();
+ case NumShapes:
+ Q_UNREACHABLE();
+ break;
+ }
+//! [qunreachable-switch]