Use C++11 static_assert() if available.
authorbmeurer@chromium.org <bmeurer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 18 Jul 2013 07:43:41 +0000 (07:43 +0000)
committerbmeurer@chromium.org <bmeurer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 18 Jul 2013 07:43:41 +0000 (07:43 +0000)
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/19684009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15736 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/checks.h

index d0a0c2b..55dc1bc 100644 (file)
@@ -230,6 +230,13 @@ inline void CheckNonEqualsHelper(const char* file,
 #define CHECK_LE(a, b) CHECK((a) <= (b))
 
 
+// Use C++11 static_assert if possible, which gives error
+// messages that are easier to understand on first sight.
+#if __cplusplus >= 201103L || \
+    (defined(__has_feature) && __has_feature(cxx_static_assert)) || \
+    (defined(__has_extension) && __has_extension(cxx_static_assert))
+#define STATIC_CHECK(test) static_assert(test, #test)
+#else
 // This is inspired by the static assertion facility in boost.  This
 // is pretty magical.  If it causes you trouble on a platform you may
 // find a fix in the boost code.
@@ -249,6 +256,7 @@ template <int> class StaticAssertionHelper { };
   typedef                                                                     \
     StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \
     SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
+#endif
 
 
 extern bool FLAG_enable_slow_asserts;