00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00030 #ifdef _MSC_VER
00031 #pragma once
00032 #endif // _MSC_VER
00033
00034 #ifndef _EXMAT_STATICASSERT_H
00035 #define _EXMAT_STATICASSERT_H
00036
00037 #include "loki/static_check.h"
00038
00039 namespace exmat {
00040
00041 #ifdef EXMAT_GNUC
00042
00043
00044 template<bool> struct CompileTimeChecker {
00045 CompileTimeChecker(...);
00046 };
00047 template<> struct CompileTimeChecker<false> {};
00048 #define StaticAssert(expr, msg) \
00049 struct ERROR_##msg { ERROR_##msg(){}; }; \
00050 (void)sizeof(CompileTimeChecker<((expr) != 0)>(ERROR_##msg()))
00051
00052 template<class chk> struct ERROR_dummy{};
00053
00054 #define StaticAssert1(expr, msg) \
00055 struct ERROR_##msg { ERROR_##msg(){}; }; \
00056 typedef ERROR_dummy<CompileTimeChecker<((expr) != 0)>(ERROR_##msg())> DummyTypedef;
00057
00058 };
00059 #else
00060
00061 template<bool> struct CompileTimeChecker {
00062 CompileTimeChecker(...);
00063 };
00065 template<> struct CompileTimeChecker<false> {};
00066 #define StaticAssert(expr, msg) \
00067 struct ERROR_##msg { ERROR_##msg(){}; }; \
00068 (void)sizeof(CompileTimeChecker<((expr) != 0)>(ERROR_##msg()))
00069
00070 template<int chk> struct ERROR_dummy{};
00071
00072 #define StaticAssert1(expr, msg) \
00073 struct ERROR_##msg { ERROR_##msg(){}; }; \
00074 typedef ERROR_dummy<sizeof(CompileTimeChecker<((expr) != 0)>(ERROR_##msg()))> DummyTypedef;
00075
00076 };
00077 #endif
00078
00079 #endif // _EXMAT_STATICASSERT_H