Reviewers: Sven Panne, danno,
Description:
Use C++11 static_assert() if available.
Please review this at https://codereview.chromium.org/19684009/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/checks.h
Index: src/checks.h
diff --git a/src/checks.h b/src/checks.h
index
d0a0c2b5acf5da52e3f2c49d3138b62904fa34df..7ad08f78cafe6a7cb4a1acea2a11baa7816dc3e2
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))
+#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;
@@ -275,6 +283,7 @@ extern bool FLAG_enable_slow_asserts;
#define ASSERT_LE(v1, v2) ((void) 0)
#define SLOW_ASSERT(condition) ((void) 0)
#endif
+
// Static asserts has no impact on runtime performance, so they can be
// safely enabled in release mode. Moreover, the ((void) 0) expression
// obeys different syntax rules than typedef's, e.g. it can't appear
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.