cml_assert.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00016 #ifndef cml_assert_h
00017 #define cml_assert_h
00018
00019 #include <cml/core/cml_meta.h>
00020
00021 namespace cml {
00022
00023
00024 #define CML_JOIN(X,Y) CML_DO_JOIN(X,Y)
00025 #define CML_DO_JOIN(X,Y) CML_DO_JOIN2(X,Y)
00026 #define CML_DO_JOIN2(X,Y) X##Y
00027
00028
00029 #define TO_STRING(X) TO_STRING2(X)
00030 #define TO_STRING2(X) #X
00031
00033 template<bool T> struct STATIC_ASSERTION_FAILURE;
00034
00036 template<> struct STATIC_ASSERTION_FAILURE<true> {
00037 typedef true_type result;
00038 enum { value = true };
00039 };
00040
00053 #define CML_STATIC_REQUIRE(_E_) \
00054 typedef typename STATIC_ASSERTION_FAILURE<(_E_)>::result \
00055 CML_JOIN(__cml_assert_test_typedef_, __LINE__)
00056
00057
00066 template<bool T, typename M> struct STATIC_ASSERTION_FAILURE_M {
00067 typename M::bogus result;
00068 };
00069
00071 template<typename M> struct STATIC_ASSERTION_FAILURE_M<true,M> {
00072 typedef true_type result;
00073 enum { value = true };
00074 };
00075
00088 #define CML_STATIC_REQUIRE_M(_E_, _M_) \
00089 typedef typename STATIC_ASSERTION_FAILURE_M<(_E_),_M_> \
00090 ::result CML_JOIN(__bogus_assert_type_, __LINE__)
00091
00092 }
00093
00094 #endif
00095
00096
00097