Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: src/checks.h

Issue 19684009: Use C++11 static_assert() if available. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix empty line in diff. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/checks.h
diff --git a/src/checks.h b/src/checks.h
index d0a0c2b5acf5da52e3f2c49d3138b62904fa34df..55dc1bc7024c79fb02b9aea9b23e6cfb996c7e2c 100644
--- a/src/checks.h
+++ b/src/checks.h
@@ -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))
Sven Panne 2013/07/18 06:45:30 autoconf by hand? ;-)
+#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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698