Commit d0f8e82b by Geoff Lang Committed by Geoff Lang

Implement META_ASSERT with static_assert if the compiler supports it.

TRAC #23948 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods
parent d1e9a9a6
...@@ -114,6 +114,11 @@ namespace gl ...@@ -114,6 +114,11 @@ namespace gl
#endif #endif
// A macro functioning as a compile-time assert to validate constant conditions // A macro functioning as a compile-time assert to validate constant conditions
#define META_ASSERT(condition) typedef int COMPILE_TIME_ASSERT_##__LINE__[static_cast<bool>(condition)?1:-1] #if defined(_MSC_VER) && _MSC_VER >= 1600
#define META_ASSERT_MSG(condition, msg) static_assert(condition, msg)
#else
#define META_ASSERT_MSG(condition, msg) typedef int COMPILE_TIME_ASSERT_##__LINE__[static_cast<bool>(condition)?1:-1]
#endif
#define META_ASSERT(condition) META_ASSERT_MSG(condition, "compile time assertion failed.")
#endif // COMMON_DEBUG_H_ #endif // COMMON_DEBUG_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment