1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/mpl/assert.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,361 @@
1.4 +
1.5 +#ifndef BOOST_MPL_ASSERT_HPP_INCLUDED
1.6 +#define BOOST_MPL_ASSERT_HPP_INCLUDED
1.7 +
1.8 +// Copyright Aleksey Gurtovoy 2000-2006
1.9 +//
1.10 +// Distributed under the Boost Software License, Version 1.0.
1.11 +// (See accompanying file LICENSE_1_0.txt or copy at
1.12 +// http://www.boost.org/LICENSE_1_0.txt)
1.13 +//
1.14 +// See http://www.boost.org/libs/mpl for documentation.
1.15 +
1.16 +// $Source: /cvsroot/boost/boost/boost/mpl/assert.hpp,v $
1.17 +// $Date: 2006/11/10 21:31:19 $
1.18 +// $Revision: 1.13.14.6 $
1.19 +
1.20 +#include <boost/mpl/not.hpp>
1.21 +#include <boost/mpl/aux_/value_wknd.hpp>
1.22 +#include <boost/mpl/aux_/nested_type_wknd.hpp>
1.23 +#include <boost/mpl/aux_/yes_no.hpp>
1.24 +#include <boost/mpl/aux_/na.hpp>
1.25 +#include <boost/mpl/aux_/adl_barrier.hpp>
1.26 +
1.27 +#include <boost/mpl/aux_/config/nttp.hpp>
1.28 +#include <boost/mpl/aux_/config/dtp.hpp>
1.29 +#include <boost/mpl/aux_/config/gcc.hpp>
1.30 +#include <boost/mpl/aux_/config/msvc.hpp>
1.31 +#include <boost/mpl/aux_/config/static_constant.hpp>
1.32 +#include <boost/mpl/aux_/config/workaround.hpp>
1.33 +
1.34 +#include <boost/preprocessor/cat.hpp>
1.35 +
1.36 +#include <boost/config.hpp> // make sure 'size_t' is placed into 'std'
1.37 +#include <cstddef>
1.38 +
1.39 +
1.40 +#if BOOST_WORKAROUND(__BORLANDC__, >= 0x560) && BOOST_WORKAROUND(__BORLANDC__, < 0x600) \
1.41 + || (BOOST_MPL_CFG_GCC != 0) \
1.42 + || BOOST_WORKAROUND(__IBMCPP__, <= 600)
1.43 +# define BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES
1.44 +#endif
1.45 +
1.46 +#if BOOST_WORKAROUND(__MWERKS__, < 0x3202) \
1.47 + || BOOST_WORKAROUND(__EDG_VERSION__, <= 238) \
1.48 + || BOOST_WORKAROUND(__BORLANDC__, < 0x600) \
1.49 + || BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840))
1.50 +# define BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER
1.51 +#endif
1.52 +
1.53 +// agurt, 10/nov/06: use enums for Borland (which cannot cope with static constants)
1.54 +// and GCC (which issues "unused variable" warnings when static constants are used
1.55 +// at a function scope)
1.56 +#if BOOST_WORKAROUND(__BORLANDC__, < 0x600) \
1.57 + || (BOOST_MPL_CFG_GCC != 0)
1.58 +# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr }
1.59 +#else
1.60 +# define BOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) BOOST_STATIC_CONSTANT(T, expr)
1.61 +#endif
1.62 +
1.63 +
1.64 +BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN
1.65 +
1.66 +struct failed {};
1.67 +
1.68 +// agurt, 24/aug/04: MSVC 7.1 workaround here and below: return/accept
1.69 +// 'assert<false>' by reference; can't apply it unconditionally -- apparently it
1.70 +// degrades the quality of GCC diagnostics
1.71 +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
1.72 +# define AUX778076_ASSERT_ARG(x) x&
1.73 +#else
1.74 +# define AUX778076_ASSERT_ARG(x) x
1.75 +#endif
1.76 +
1.77 +template< bool C > struct assert { typedef void* type; };
1.78 +template<> struct assert<false> { typedef AUX778076_ASSERT_ARG(assert) type; };
1.79 +
1.80 +template< bool C >
1.81 +int assertion_failed( typename assert<C>::type );
1.82 +
1.83 +template< bool C >
1.84 +struct assertion
1.85 +{
1.86 + static int failed( assert<false> );
1.87 +};
1.88 +
1.89 +template<>
1.90 +struct assertion<true>
1.91 +{
1.92 + static int failed( void* );
1.93 +};
1.94 +
1.95 +struct assert_
1.96 +{
1.97 +#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
1.98 + template< typename T1, typename T2 = na, typename T3 = na, typename T4 = na > struct types {};
1.99 +#endif
1.100 + static assert_ const arg;
1.101 + enum relations { equal = 1, not_equal, greater, greater_equal, less, less_equal };
1.102 +};
1.103 +
1.104 +
1.105 +#if !defined(BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES)
1.106 +
1.107 +bool operator==( failed, failed );
1.108 +bool operator!=( failed, failed );
1.109 +bool operator>( failed, failed );
1.110 +bool operator>=( failed, failed );
1.111 +bool operator<( failed, failed );
1.112 +bool operator<=( failed, failed );
1.113 +
1.114 +#if defined(__EDG_VERSION__)
1.115 +template< bool (*)(failed, failed), long x, long y > struct assert_relation {};
1.116 +# define BOOST_MPL_AUX_ASSERT_RELATION(x, y, r) assert_relation<r,x,y>
1.117 +#else
1.118 +template< BOOST_MPL_AUX_NTTP_DECL(long, x), BOOST_MPL_AUX_NTTP_DECL(long, y), bool (*)(failed, failed) >
1.119 +struct assert_relation {};
1.120 +# define BOOST_MPL_AUX_ASSERT_RELATION(x, y, r) assert_relation<x,y,r>
1.121 +#endif
1.122 +
1.123 +#else // BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES
1.124 +
1.125 +boost::mpl::aux::weighted_tag<1>::type operator==( assert_, assert_ );
1.126 +boost::mpl::aux::weighted_tag<2>::type operator!=( assert_, assert_ );
1.127 +boost::mpl::aux::weighted_tag<3>::type operator>( assert_, assert_ );
1.128 +boost::mpl::aux::weighted_tag<4>::type operator>=( assert_, assert_ );
1.129 +boost::mpl::aux::weighted_tag<5>::type operator<( assert_, assert_ );
1.130 +boost::mpl::aux::weighted_tag<6>::type operator<=( assert_, assert_ );
1.131 +
1.132 +template< assert_::relations r, long x, long y > struct assert_relation {};
1.133 +
1.134 +#endif
1.135 +
1.136 +
1.137 +#if !defined(BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER)
1.138 +
1.139 +template< bool > struct assert_arg_pred_impl { typedef int type; };
1.140 +template<> struct assert_arg_pred_impl<true> { typedef void* type; };
1.141 +
1.142 +template< typename P > struct assert_arg_pred
1.143 +{
1.144 + typedef typename P::type p_type;
1.145 + typedef typename assert_arg_pred_impl< p_type::value >::type type;
1.146 +};
1.147 +
1.148 +template< typename P > struct assert_arg_pred_not
1.149 +{
1.150 + typedef typename P::type p_type;
1.151 + BOOST_MPL_AUX_ASSERT_CONSTANT( bool, p = !p_type::value );
1.152 + typedef typename assert_arg_pred_impl<p>::type type;
1.153 +};
1.154 +
1.155 +template< typename Pred >
1.156 +failed ************ (Pred::************
1.157 + assert_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type )
1.158 + );
1.159 +
1.160 +template< typename Pred >
1.161 +failed ************ (boost::mpl::not_<Pred>::************
1.162 + assert_not_arg( void (*)(Pred), typename assert_arg_pred_not<Pred>::type )
1.163 + );
1.164 +
1.165 +template< typename Pred >
1.166 +AUX778076_ASSERT_ARG(assert<false>)
1.167 +assert_arg( void (*)(Pred), typename assert_arg_pred_not<Pred>::type );
1.168 +
1.169 +template< typename Pred >
1.170 +AUX778076_ASSERT_ARG(assert<false>)
1.171 +assert_not_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type );
1.172 +
1.173 +
1.174 +#else // BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER
1.175 +
1.176 +template< bool c, typename Pred > struct assert_arg_type_impl
1.177 +{
1.178 + typedef failed ************ Pred::* mwcw83_wknd;
1.179 + typedef mwcw83_wknd ************* type;
1.180 +};
1.181 +
1.182 +template< typename Pred > struct assert_arg_type_impl<true,Pred>
1.183 +{
1.184 + typedef AUX778076_ASSERT_ARG(assert<false>) type;
1.185 +};
1.186 +
1.187 +template< typename Pred > struct assert_arg_type
1.188 + : assert_arg_type_impl< BOOST_MPL_AUX_VALUE_WKND(BOOST_MPL_AUX_NESTED_TYPE_WKND(Pred))::value, Pred >
1.189 +{
1.190 +};
1.191 +
1.192 +template< typename Pred >
1.193 +typename assert_arg_type<Pred>::type
1.194 +assert_arg(void (*)(Pred), int);
1.195 +
1.196 +template< typename Pred >
1.197 +typename assert_arg_type< boost::mpl::not_<Pred> >::type
1.198 +assert_not_arg(void (*)(Pred), int);
1.199 +
1.200 +# if !defined(BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES)
1.201 +template< long x, long y, bool (*r)(failed, failed) >
1.202 +typename assert_arg_type_impl< false,BOOST_MPL_AUX_ASSERT_RELATION(x,y,r) >::type
1.203 +assert_rel_arg( BOOST_MPL_AUX_ASSERT_RELATION(x,y,r) );
1.204 +# else
1.205 +template< assert_::relations r, long x, long y >
1.206 +typename assert_arg_type_impl< false,assert_relation<r,x,y> >::type
1.207 +assert_rel_arg( assert_relation<r,x,y> );
1.208 +# endif
1.209 +
1.210 +#endif // BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER
1.211 +
1.212 +#undef AUX778076_ASSERT_ARG
1.213 +
1.214 +BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE
1.215 +
1.216 +
1.217 +// BOOST_MPL_ASSERT((pred<x,...>))
1.218 +
1.219 +#define BOOST_MPL_ASSERT(pred) \
1.220 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.221 + std::size_t \
1.222 + , BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.223 + boost::mpl::assertion_failed<false>( \
1.224 + boost::mpl::assert_arg( (void (*) pred)0, 1 ) \
1.225 + ) \
1.226 + ) \
1.227 + ) \
1.228 +/**/
1.229 +
1.230 +// BOOST_MPL_ASSERT_NOT((pred<x,...>))
1.231 +
1.232 +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
1.233 +# define BOOST_MPL_ASSERT_NOT(pred) \
1.234 +enum { \
1.235 + BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.236 + boost::mpl::assertion<false>::failed( \
1.237 + boost::mpl::assert_not_arg( (void (*) pred)0, 1 ) \
1.238 + ) \
1.239 + ) \
1.240 +}\
1.241 +/**/
1.242 +#else
1.243 +# define BOOST_MPL_ASSERT_NOT(pred) \
1.244 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.245 + std::size_t \
1.246 + , BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.247 + boost::mpl::assertion_failed<false>( \
1.248 + boost::mpl::assert_not_arg( (void (*) pred)0, 1 ) \
1.249 + ) \
1.250 + ) \
1.251 + ) \
1.252 +/**/
1.253 +#endif
1.254 +
1.255 +// BOOST_MPL_ASSERT_RELATION(x, ==|!=|<=|<|>=|>, y)
1.256 +
1.257 +#if defined(BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES)
1.258 +
1.259 +# if !defined(BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER)
1.260 +// agurt, 9/nov/06: 'enum' below is a workaround for gcc 4.0.4/4.1.1 bugs #29522 and #29518
1.261 +# define BOOST_MPL_ASSERT_RELATION(x, rel, y) \
1.262 +enum { BOOST_PP_CAT(mpl_assert_rel_value,__LINE__) = (x rel y) }; \
1.263 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.264 + std::size_t \
1.265 + , BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.266 + boost::mpl::assertion_failed<BOOST_PP_CAT(mpl_assert_rel_value,__LINE__)>( \
1.267 + (boost::mpl::failed ************ ( boost::mpl::assert_relation< \
1.268 + boost::mpl::assert_::relations( sizeof( \
1.269 + boost::mpl::assert_::arg rel boost::mpl::assert_::arg \
1.270 + ) ) \
1.271 + , x \
1.272 + , y \
1.273 + >::************)) 0 ) \
1.274 + ) \
1.275 + ) \
1.276 +/**/
1.277 +# else
1.278 +# define BOOST_MPL_ASSERT_RELATION(x, rel, y) \
1.279 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.280 + std::size_t \
1.281 + , BOOST_PP_CAT(mpl_assert_rel,__LINE__) = sizeof( \
1.282 + boost::mpl::assert_::arg rel boost::mpl::assert_::arg \
1.283 + ) \
1.284 + ); \
1.285 +BOOST_MPL_AUX_ASSERT_CONSTANT( bool, BOOST_PP_CAT(mpl_assert_rel_value,__LINE__) = (x rel y) ); \
1.286 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.287 + std::size_t \
1.288 + , BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.289 + boost::mpl::assertion_failed<BOOST_PP_CAT(mpl_assert_rel_value,__LINE__)>( \
1.290 + boost::mpl::assert_rel_arg( boost::mpl::assert_relation< \
1.291 + boost::mpl::assert_::relations(BOOST_PP_CAT(mpl_assert_rel,__LINE__)) \
1.292 + , x \
1.293 + , y \
1.294 + >() ) \
1.295 + ) \
1.296 + ) \
1.297 + ) \
1.298 +/**/
1.299 +# endif
1.300 +
1.301 +#else // !BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES
1.302 +
1.303 +# if defined(BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER)
1.304 +# define BOOST_MPL_ASSERT_RELATION(x, rel, y) \
1.305 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.306 + std::size_t \
1.307 + , BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.308 + boost::mpl::assertion_failed<(x rel y)>( boost::mpl::assert_rel_arg( \
1.309 + boost::mpl::BOOST_MPL_AUX_ASSERT_RELATION(x,y,(&boost::mpl::operator rel))() \
1.310 + ) ) \
1.311 + ) \
1.312 + ) \
1.313 +/**/
1.314 +# else
1.315 +# define BOOST_MPL_ASSERT_RELATION(x, rel, y) \
1.316 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.317 + std::size_t \
1.318 + , BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.319 + boost::mpl::assertion_failed<(x rel y)>( (boost::mpl::failed ************ ( \
1.320 + boost::mpl::BOOST_MPL_AUX_ASSERT_RELATION(x,y,(&boost::mpl::operator rel))::************))0 ) \
1.321 + ) \
1.322 + ) \
1.323 +/**/
1.324 +# endif
1.325 +
1.326 +#endif
1.327 +
1.328 +
1.329 +// BOOST_MPL_ASSERT_MSG( (pred<x,...>::value), USER_PROVIDED_MESSAGE, (types<x,...>) )
1.330 +
1.331 +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202))
1.332 +# define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \
1.333 +struct msg; \
1.334 +typedef struct BOOST_PP_CAT(msg,__LINE__) : boost::mpl::assert_ \
1.335 +{ \
1.336 + using boost::mpl::assert_::types; \
1.337 + static boost::mpl::failed ************ (msg::************ assert_arg()) types_ \
1.338 + { return 0; } \
1.339 +} BOOST_PP_CAT(mpl_assert_arg,__LINE__); \
1.340 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.341 + std::size_t \
1.342 + , BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.343 + boost::mpl::assertion<(c)>::failed( BOOST_PP_CAT(mpl_assert_arg,__LINE__)::assert_arg() ) \
1.344 + ) \
1.345 + ) \
1.346 +/**/
1.347 +#else
1.348 +# define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \
1.349 +struct msg; \
1.350 +typedef struct BOOST_PP_CAT(msg,__LINE__) : boost::mpl::assert_ \
1.351 +{ \
1.352 + static boost::mpl::failed ************ (msg::************ assert_arg()) types_ \
1.353 + { return 0; } \
1.354 +} BOOST_PP_CAT(mpl_assert_arg,__LINE__); \
1.355 +BOOST_MPL_AUX_ASSERT_CONSTANT( \
1.356 + std::size_t \
1.357 + , BOOST_PP_CAT(mpl_assertion_in_line_,__LINE__) = sizeof( \
1.358 + boost::mpl::assertion_failed<(c)>( BOOST_PP_CAT(mpl_assert_arg,__LINE__)::assert_arg() ) \
1.359 + ) \
1.360 + ) \
1.361 +/**/
1.362 +#endif
1.363 +
1.364 +#endif // BOOST_MPL_ASSERT_HPP_INCLUDED