static_assert.h

Go to the documentation of this file.
00001 #ifndef STATIC_ASSERT_HPP
00002 #define STATIC_ASSERT_HPP
00003 
00009 #include <config.h>
00010 namespace util
00011 {
00012 
00013 #ifndef GXX_USE_GNUXX0X
00014 
00015   // Extracted from boost static_asset.h ...
00016   template <bool x> struct STATIC_ASSERTION_FAILURE;
00017   template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
00018   template<int x> struct static_assert_test{};
00019 
00020 #define JOIN( X, Y ) DO_JOIN( X, Y )
00021 #define DO_JOIN( X, Y ) DO_JOIN2(X,Y)
00022 #define DO_JOIN2( X, Y ) X##Y
00023 
00048 #  define STATIC_ASSERT(B, txt) \
00049    typedef util::static_assert_test<\
00050       sizeof(util::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
00051          JOIN(static_assert_typedef_, __LINE__)
00052 
00053 #else
00054 
00055 #  define STATIC_ASSERT(B, txt) static_assert(B, txt)
00056 
00057 #endif
00058 
00059 }
00060 
00061 #endif // STATIC_ASSERT_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Fri May 31 15:37:53 2013 for VVE by  doxygen 1.6.3