[0070] Make use of C++11's static_assert if possible.

This commit is contained in:
LordJZ 2012-08-13 00:40:11 +04:00 committed by Antz
parent 81787fa460
commit 856342bb7c
3 changed files with 10 additions and 7 deletions

View file

@ -119,9 +119,18 @@ typedef uint16 WORD;
typedef uint32 DWORD; typedef uint32 DWORD;
#endif // COMPILER #endif // COMPILER
#define CONCAT(x, y) CONCAT1(x, y)
#define CONCAT1(x, y) x##y
#define STATIC_ASSERT_WORKAROUND(expr, msg) typedef char CONCAT(static_assert_failed_at_line_, __LINE__) [(expr) ? 1 : -1]
#if COMPILER == COMPILER_GNU #if COMPILER == COMPILER_GNU
# if !defined(__GXX_EXPERIMENTAL_CXX0X__) || (__GNUC__ < 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) # if !defined(__GXX_EXPERIMENTAL_CXX0X__) || (__GNUC__ < 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ < 7)
# define override # define override
# define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b)
# endif
#elif COMPILER == COMPILER_MICROSOFT
# if _MSC_VER < 1600
# define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b)
# endif # endif
#endif #endif

View file

@ -44,12 +44,6 @@ namespace Movement
return ms / 1000.f; return ms / 1000.f;
} }
#ifndef static_assert
#define CONCAT(x, y) CONCAT1 (x, y)
#define CONCAT1(x, y) x##y
#define static_assert(expr, msg) typedef char CONCAT(static_assert_failed_at_line_, __LINE__) [(expr) ? 1 : -1]
#endif
template<class T, T limit> template<class T, T limit>
class counter class counter
{ {

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "0069" #define REVISION_NR "0070"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__