MSVC's throw() behaviour matches the C++11 noexcept, so use it
authorThiago Macieira <thiago.macieira@intel.com>
Thu, 2 Aug 2012 20:17:27 +0000 (22:17 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 6 Aug 2012 18:31:38 +0000 (20:31 +0200)
This allows code using methods marked Q_DECL_NOEXCEPT to benefit from
optimisations before MSVC supports the C++11 keyword. Even MSVC 2012
doesn't have it yet.

Using throw() in other compilers is not a good idea because they might
actually be implementing the C++ standard -- which is broken.

Change-Id: Id07ab4fe40a641583d5285d5abb536998bc419ba
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
src/corelib/global/qcompilerdetection.h

index 6cc754c..9a9e78b 100644 (file)
 #    define Q_COMPILER_VARIADIC_MACROS
 #  endif
 
+// make sure that these aren't defined when Q_COMPILER_NOEXCEPT is defined
+#  define Q_DECL_NOEXCEPT  throw()
+#  define Q_DECL_NOEXCEPT_EXPR(x)
+
 #if defined(Q_CC_MSVC) && _MSC_VER >= 1600
 #      define Q_COMPILER_RVALUE_REFS
 #      define Q_COMPILER_AUTO_TYPE
 #ifdef Q_COMPILER_NOEXCEPT
 # define Q_DECL_NOEXCEPT noexcept
 # define Q_DECL_NOEXCEPT_EXPR(x) noexcept(x)
-#else
+#elif !defined(Q_DECL_NOEXCEPT)
 # define Q_DECL_NOEXCEPT
 # define Q_DECL_NOEXCEPT_EXPR(x)
 #endif