Effective implementation of algorithms (Master Thesis)
Effective and error-free implementation of algorithms
|
00001 #ifndef H_STATIC_ASSERT 00002 #define H_STATIC_ASSERT 00003 00007 namespace utils { 00008 namespace static_assert_ { 00009 00013 template <bool x> struct STATIC_ASSERTION_FAILURE; 00014 00018 template <> struct STATIC_ASSERTION_FAILURE<true> { 00019 enum { value = 1 }; 00020 }; 00021 00025 template<int x> struct static_assert_test{}; 00026 00027 // We need two definitions because otherwise JOIN(x, __LINE__) will 00028 // end up as "x__LINE__" 00029 #define __JOIN(X, Y) __JOIN2(X, Y) 00030 #define __JOIN2(X, Y) X##Y 00031 00042 #define STATIC_ASSERT( B, MSG ) \ 00043 typedef ::utils::static_assert_::static_assert_test<\ 00044 sizeof(::utils::static_assert_::STATIC_ASSERTION_FAILURE<(bool) (B)>)> \ 00045 __JOIN(static_assert_on_line_, __LINE__); 00046 00047 } // namespace static_assert 00048 } // namespace utils 00049 #endif