static_assert.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef SOFA_HELPER_STATIC_ASSERT_H
00034 #define SOFA_HELPER_STATIC_ASSERT_H
00035
00036 #include <sofa/helper/system/config.h>
00037
00038 namespace sofa
00039 {
00040
00041 namespace helper
00042 {
00043
00044 #ifndef BOOST_STATIC_ASSERT
00045 #define BOOST_STATIC_ASSERT_HPP
00046
00047 template <bool x> struct STATIC_ASSERTION_FAILURE{};
00048 template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
00049 template<int x> struct static_assert_test{};
00050
00051 #if defined(_MSC_VER)
00052 #define BOOST_STATIC_ASSERT( B ) \
00053 typedef ::sofa::helper::static_assert_test<\
00054 sizeof(::sofa::helper::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
00055 sofa_concat(boost_static_assert_typedef_,__LINE__)
00056 #elif (defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) || (defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4)))
00057
00058
00059 # define BOOST_STATIC_ASSERT( B ) \
00060 typedef char sofa_concat(boost_static_assert_typedef_, __LINE__) \
00061 [ ::sofa::helper::STATIC_ASSERTION_FAILURE< (bool)( B ) >::value ]
00062 #elif defined(__sgi)
00063
00064 #define BOOST_STATIC_ASSERT( B ) \
00065 BOOST_STATIC_CONSTANT(bool, \
00066 sofa_concat(boost_static_assert_test_, __LINE__) = ( B )); \
00067 typedef ::sofa::helper::static_assert_test<\
00068 sizeof(::sofa::helper::STATIC_ASSERTION_FAILURE< \
00069 sofa_concat(boost_static_assert_test_, __LINE__) >)>\
00070 sofa_concat(boost_static_assert_typedef_, __LINE__)
00071 #else
00072
00073 #define BOOST_STATIC_ASSERT( B ) \
00074 typedef ::sofa::helper::static_assert_test<\
00075 sizeof(::sofa::helper::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
00076 sofa_concat(boost_static_assert_typedef_, __LINE__)
00077 #endif
00078
00079 #endif
00080 }
00081
00082 }
00083
00084 #endif