static_assert.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                              SOFA :: Framework                              *
00020 *                                                                             *
00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,*
00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza,  *
00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy          *
00024 *                                                                             *
00025 * Contact information: contact@sofa-framework.org                             *
00026 ******************************************************************************/
00027 //  (C) Copyright John Maddock 2000.
00028 //  Use, modification and distribution are subject to the
00029 //  Boost Software License, Version 1.0. (See accompanying file
00030 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
00031 
00032 //  See http://www.boost.org/libs/static_assert for documentation.
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 // agurt 15/sep/02: a special care is needed to force Intel C++ and GCC 3.3/3.4 to issue an error 
00058 // instead of warning in case of failure
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 // special version for SGI MIPSpro compiler
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 // generic version
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 } // namespace helper
00081 
00082 } // namespace sofa
00083 
00084 #endif

Generated on Sun Nov 23 02:29:30 2008 for Sofa by  doxygen 1.5.7.1