14 #ifndef BOOST_STATIC_ASSERT_HPP 15 #define BOOST_STATIC_ASSERT_HPP 20 #if defined(__GNUC__) && !defined(__GXX_EXPERIMENTAL_CXX0X__) 26 #pragma GCC system_header 29 #ifndef BOOST_NO_CXX11_STATIC_ASSERT 30 # ifndef BOOST_NO_CXX11_VARIADIC_MACROS 31 # define BOOST_STATIC_ASSERT_MSG( ... ) static_assert(__VA_ARGS__) 33 # define BOOST_STATIC_ASSERT_MSG( B, Msg ) BOOST_STATIC_ASSERT( B ) 36 # define BOOST_STATIC_ASSERT_MSG( B, Msg ) BOOST_STATIC_ASSERT( B ) 42 #define BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS 45 #if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4)) 47 # define BOOST_SA_GCC_WORKAROUND 54 #if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))) 55 # ifndef BOOST_NO_CXX11_VARIADIC_MACROS 56 # define BOOST_STATIC_ASSERT_BOOL_CAST( ... ) ((__VA_ARGS__) == 0 ? false : true) 58 # define BOOST_STATIC_ASSERT_BOOL_CAST( x ) ((x) == 0 ? false : true) 61 # ifndef BOOST_NO_CXX11_VARIADIC_MACROS 62 # define BOOST_STATIC_ASSERT_BOOL_CAST( ... ) (bool)(__VA_ARGS__) 64 # define BOOST_STATIC_ASSERT_BOOL_CAST(x) (bool)(x) 70 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) 71 # define BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) 73 # define BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE 76 #ifndef BOOST_NO_CXX11_STATIC_ASSERT 77 # ifndef BOOST_NO_CXX11_VARIADIC_MACROS 78 # define BOOST_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__) 80 # define BOOST_STATIC_ASSERT( B ) static_assert(B, #B) 87 template <
bool x>
struct STATIC_ASSERTION_FAILURE;
89 template <>
struct STATIC_ASSERTION_FAILURE<true> {
enum {
value = 1 }; };
92 template<
int x>
struct static_assert_test{};
118 #if !defined(BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS) 120 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) 123 #define BOOST_STATIC_ASSERT( B ) \ 124 typedef ::boost::static_assert_test<\ 125 sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)\ 126 > boost_static_assert_typedef_ 127 #elif defined(BOOST_MSVC) && defined(BOOST_NO_CXX11_VARIADIC_MACROS) 128 #define BOOST_STATIC_ASSERT( B ) \ 129 typedef ::boost::static_assert_test<\ 130 sizeof(::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST ( B ) >)>\ 131 BOOST_JOIN(boost_static_assert_typedef_, __COUNTER__) 132 #elif defined(BOOST_MSVC) 133 #define BOOST_STATIC_ASSERT(...) \ 134 typedef ::boost::static_assert_test<\ 135 sizeof(::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST (__VA_ARGS__) >)>\ 136 BOOST_JOIN(boost_static_assert_typedef_, __COUNTER__) 137 #elif (defined(BOOST_INTEL_CXX_VERSION) || defined(BOOST_SA_GCC_WORKAROUND)) && defined(BOOST_NO_CXX11_VARIADIC_MACROS) 140 # define BOOST_STATIC_ASSERT( B ) \ 141 typedef char BOOST_JOIN(boost_static_assert_typedef_, __LINE__) \ 142 [ ::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST( B ) >::value ] 143 #elif (defined(BOOST_INTEL_CXX_VERSION) || defined(BOOST_SA_GCC_WORKAROUND)) && !defined(BOOST_NO_CXX11_VARIADIC_MACROS) 146 # define BOOST_STATIC_ASSERT(...) \ 147 typedef char BOOST_JOIN(boost_static_assert_typedef_, __LINE__) \ 148 [ ::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST( __VA_ARGS__ ) >::value ] 151 #define BOOST_STATIC_ASSERT( B ) \ 152 BOOST_STATIC_CONSTANT(bool, \ 153 BOOST_JOIN(boost_static_assert_test_, __LINE__) = ( B )); \ 154 typedef ::boost::static_assert_test<\ 155 sizeof(::boost::STATIC_ASSERTION_FAILURE< \ 156 BOOST_JOIN(boost_static_assert_test_, __LINE__) >)>\ 157 BOOST_JOIN(boost_static_assert_typedef_, __LINE__) 158 #elif BOOST_WORKAROUND(__MWERKS__, <= 0x3003) 160 #define BOOST_STATIC_ASSERT( B ) \ 161 BOOST_STATIC_CONSTANT(int, \ 162 BOOST_JOIN(boost_static_assert_test_, __LINE__) = \ 163 sizeof(::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST( B ) >) ) 166 # ifndef BOOST_NO_CXX11_VARIADIC_MACROS 167 # define BOOST_STATIC_ASSERT( ... ) \ 168 typedef ::boost::static_assert_test<\ 169 sizeof(::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST( __VA_ARGS__ ) >)>\ 170 BOOST_JOIN(boost_static_assert_typedef_, __LINE__) BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE 172 # define BOOST_STATIC_ASSERT( B ) \ 173 typedef ::boost::static_assert_test<\ 174 sizeof(::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST( B ) >)>\ 175 BOOST_JOIN(boost_static_assert_typedef_, __LINE__) BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE 181 # ifndef BOOST_NO_CXX11_VARIADIC_MACROS 182 # define BOOST_STATIC_ASSERT( ... ) \ 183 enum { BOOST_JOIN(boost_static_assert_enum_, __LINE__) \ 184 = sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( __VA_ARGS__ ) >) } 186 # define BOOST_STATIC_ASSERT(B) \ 187 enum { BOOST_JOIN(boost_static_assert_enum_, __LINE__) \ 188 = sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >) } 191 #endif // defined(BOOST_NO_CXX11_STATIC_ASSERT) 193 #endif // BOOST_STATIC_ASSERT_HPP BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.