00001 #ifndef DUNE_STATIC_ASSERT_HH
00002 #define DUNE_STATIC_ASSERT_HH
00003
00021 template <bool condition>
00022 struct IsTrue
00023 {
00024 static void no() {};
00025 };
00026
00027 template <>
00028 struct IsTrue<true>
00029 {
00030 static void yes() {};
00031 };
00032
00033
00034 #include<iostream>
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #define CPPMAGIC_JOIN( X, Y ) CPPMAGIC_DO_JOIN( X, Y )
00046 #define CPPMAGIC_DO_JOIN( X, Y ) CPPMAGIC_DO_JOIN2(X,Y)
00047 #define CPPMAGIC_DO_JOIN2( X, Y ) X##Y
00048
00049 template <bool x> struct static_assert_failure;
00050
00051 template <> struct static_assert_failure<true> { };
00052
00053 template<int x> struct static_assert_test{};
00054
00060 #define dune_static_assert(B,MSG) \
00061 typedef static_assert_test<\
00062 sizeof(static_assert_failure< (bool)( B )>)\
00063 > CPPMAGIC_JOIN(dune_static_assert_typedef_, __LINE__)
00064
00065 #endif