1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/static_assert.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,118 @@
1.4 +// (C) Copyright John Maddock 2000.
1.5 +// Use, modification and distribution are subject to the
1.6 +// Boost Software License, Version 1.0. (See accompanying file
1.7 +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1.8 +
1.9 +// See http://www.boost.org/libs/static_assert for documentation.
1.10 +
1.11 +/*
1.12 + Revision history:
1.13 + 02 August 2000
1.14 + Initial version.
1.15 +*/
1.16 +
1.17 +#ifndef BOOST_STATIC_ASSERT_HPP
1.18 +#define BOOST_STATIC_ASSERT_HPP
1.19 +
1.20 +#include <boost/config.hpp>
1.21 +#include <boost/detail/workaround.hpp>
1.22 +
1.23 +#ifdef __BORLANDC__
1.24 +//
1.25 +// workaround for buggy integral-constant expression support:
1.26 +#define BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS
1.27 +#endif
1.28 +
1.29 +#if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
1.30 +// gcc 3.3 and 3.4 don't produce good error messages with the default version:
1.31 +# define BOOST_SA_GCC_WORKAROUND
1.32 +#endif
1.33 +
1.34 +namespace boost{
1.35 +
1.36 +// HP aCC cannot deal with missing names for template value parameters
1.37 +template <bool x> struct STATIC_ASSERTION_FAILURE;
1.38 +
1.39 +template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
1.40 +
1.41 +// HP aCC cannot deal with missing names for template value parameters
1.42 +template<int x> struct static_assert_test{};
1.43 +
1.44 +}
1.45 +
1.46 +//
1.47 +// Implicit instantiation requires that all member declarations be
1.48 +// instantiated, but that the definitions are *not* instantiated.
1.49 +//
1.50 +// It's not particularly clear how this applies to enum's or typedefs;
1.51 +// both are described as declarations [7.1.3] and [7.2] in the standard,
1.52 +// however some compilers use "delayed evaluation" of one or more of
1.53 +// these when implicitly instantiating templates. We use typedef declarations
1.54 +// by default, but try defining BOOST_USE_ENUM_STATIC_ASSERT if the enum
1.55 +// version gets better results from your compiler...
1.56 +//
1.57 +// Implementation:
1.58 +// Both of these versions rely on sizeof(incomplete_type) generating an error
1.59 +// message containing the name of the incomplete type. We use
1.60 +// "STATIC_ASSERTION_FAILURE" as the type name here to generate
1.61 +// an eye catching error message. The result of the sizeof expression is either
1.62 +// used as an enum initialiser, or as a template argument depending which version
1.63 +// is in use...
1.64 +// Note that the argument to the assert is explicitly cast to bool using old-
1.65 +// style casts: too many compilers currently have problems with static_cast
1.66 +// when used inside integral constant expressions.
1.67 +//
1.68 +#if !defined(BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS)
1.69 +
1.70 +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
1.71 +// __LINE__ macro broken when -ZI is used see Q199057
1.72 +// fortunately MSVC ignores duplicate typedef's.
1.73 +#define BOOST_STATIC_ASSERT( B ) \
1.74 + typedef ::boost::static_assert_test<\
1.75 + sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)\
1.76 + > boost_static_assert_typedef_
1.77 +#elif defined(BOOST_MSVC)
1.78 +#define BOOST_STATIC_ASSERT( B ) \
1.79 + typedef ::boost::static_assert_test<\
1.80 + sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
1.81 + BOOST_JOIN(boost_static_assert_typedef_, __COUNTER__)
1.82 +#elif defined(BOOST_INTEL_CXX_VERSION) || defined(BOOST_SA_GCC_WORKAROUND)
1.83 +// agurt 15/sep/02: a special care is needed to force Intel C++ issue an error
1.84 +// instead of warning in case of failure
1.85 +# define BOOST_STATIC_ASSERT( B ) \
1.86 + typedef char BOOST_JOIN(boost_static_assert_typedef_, __LINE__) \
1.87 + [ ::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >::value ]
1.88 +#elif defined(__sgi)
1.89 +// special version for SGI MIPSpro compiler
1.90 +#define BOOST_STATIC_ASSERT( B ) \
1.91 + BOOST_STATIC_CONSTANT(bool, \
1.92 + BOOST_JOIN(boost_static_assert_test_, __LINE__) = ( B )); \
1.93 + typedef ::boost::static_assert_test<\
1.94 + sizeof(::boost::STATIC_ASSERTION_FAILURE< \
1.95 + BOOST_JOIN(boost_static_assert_test_, __LINE__) >)>\
1.96 + BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
1.97 +#elif BOOST_WORKAROUND(__MWERKS__, <= 0x3003)
1.98 +// special version for CodeWarrior <= 8.x
1.99 +#define BOOST_STATIC_ASSERT( B ) \
1.100 + BOOST_STATIC_CONSTANT(int, \
1.101 + BOOST_JOIN(boost_static_assert_test_, __LINE__) = \
1.102 + sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >) )
1.103 +#else
1.104 +// generic version
1.105 +#define BOOST_STATIC_ASSERT( B ) \
1.106 + typedef ::boost::static_assert_test<\
1.107 + sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
1.108 + BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
1.109 +#endif
1.110 +
1.111 +#else
1.112 +// alternative enum based implementation:
1.113 +#define BOOST_STATIC_ASSERT( B ) \
1.114 + enum { BOOST_JOIN(boost_static_assert_enum_, __LINE__) \
1.115 + = sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >) }
1.116 +#endif
1.117 +
1.118 +
1.119 +#endif // BOOST_STATIC_ASSERT_HPP
1.120 +
1.121 +