summaryrefslogtreecommitdiff
path: root/src/debug/static_assert.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug/static_assert.h')
-rw-r--r--src/debug/static_assert.h35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/debug/static_assert.h b/src/debug/static_assert.h
index 04833d844..49248611d 100644
--- a/src/debug/static_assert.h
+++ b/src/debug/static_assert.h
@@ -2,7 +2,7 @@
// vim:tabstop=4:shiftwidth=4:expandtab:
/*
- * Copyright (C) 2004-2008 Wu Yongwei <adah at users dot sourceforge dot net>
+ * Copyright (C) 2004-2013 Wu Yongwei <adah at users dot sourceforge dot net>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
@@ -24,30 +24,39 @@
* This file is part of Stones of Nvwa:
* http://sourceforge.net/projects/nvwa
*
- * original version changed for ManaPlus
- *
- * Copyright (C) 2011-2017 The ManaPlus Developers
*/
/**
- * @file static_assert.h
- *
- * Template class to check validity during compilation time (adapted from Loki).
+ * @file static_assert.h
*
- * @version 1.2, 2005/11/22
- * @author Wu Yongwei
+ * Template class to check validity duing compile time (adapted from Loki).
*
+ * @date 2013-09-07
*/
#ifndef STATIC_ASSERT
-template <bool> struct __nvwa_compile_time_error;
-template <> struct __nvwa_compile_time_error<true> {};
+#include "debug/c++11.h"
+
+#if HAVE_CXX11_STATIC_ASSERT
+
+#define STATIC_ASSERT(_Expr, _Msg) static_assert(_Expr, #_Msg)
+
+#else
+
+namespace nvwa {
+
+template <bool> struct compile_time_error;
+template <> struct compile_time_error<true> {};
#define STATIC_ASSERT(_Expr, _Msg) \
{ \
- __nvwa_compile_time_error<((_Expr) != 0)> ERROR_##_Msg; \
+ nvwa::compile_time_error<((_Expr) != 0)> ERROR_##_Msg; \
(void)ERROR_##_Msg; \
}
-#endif // STATIC_ASSERT
+}
+
+#endif // HAVE_CXX11_STATIC_ASSERT
+
+#endif // STATIC_ASSERT