From 6e78a8f0f4a18b42eb08ca8ac8e27c32b3ba02d5 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Thu, 23 May 2013 14:38:22 +0000 Subject: [PATCH] Merge [81027] from the trunk. [SVN r84442] --- include/boost/mpl/assert.hpp | 70 +++++++++++++++++++++++++++++++++++- test/assert.cpp | 11 ++++++ 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/include/boost/mpl/assert.hpp b/include/boost/mpl/assert.hpp index 7210fa2..8bfd3e1 100644 --- a/include/boost/mpl/assert.hpp +++ b/include/boost/mpl/assert.hpp @@ -34,6 +34,9 @@ #include // make sure 'size_t' is placed into 'std' #include +#if BOOST_WORKAROUND(BOOST_MSVC, == 1700) +#include +#endif #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) \ || (BOOST_MPL_CFG_GCC != 0) \ @@ -131,8 +134,38 @@ template< assert_::relations r, long x, long y > struct assert_relation {}; #endif +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1700) -#if !defined(BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER) +template +struct extract_assert_pred; + +template +struct extract_assert_pred { typedef Pred type; }; + +template +struct eval_assert { + typedef typename extract_assert_pred::type P; + typedef typename P::type p_type; + typedef typename ::boost::mpl::if_c), + failed ************ P::************ + >::type type; +}; + +template +struct eval_assert_not { + typedef typename extract_assert_pred::type P; + typedef typename P::type p_type; + typedef typename ::boost::mpl::if_c), + failed ************ ::boost::mpl::not_

::************ + >::type type; +}; + +template< typename T > +T make_assert_arg(); + +#elif !defined(BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER) template< bool > struct assert_arg_pred_impl { typedef int type; }; template<> struct assert_arg_pred_impl { typedef void* type; }; @@ -211,6 +244,39 @@ assert_rel_arg( assert_relation ); BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE +#if BOOST_WORKAROUND(BOOST_MSVC, == 1700) + +// BOOST_MPL_ASSERT((pred)) + +#define BOOST_MPL_ASSERT(pred) \ +BOOST_MPL_AUX_ASSERT_CONSTANT( \ + std::size_t \ + , BOOST_PP_CAT(mpl_assertion_in_line_,BOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ + boost::mpl::assertion_failed( \ + boost::mpl::make_assert_arg< \ + typename boost::mpl::eval_assert::type \ + >() \ + ) \ + ) \ + ) \ +/**/ + +// BOOST_MPL_ASSERT_NOT((pred)) + +#define BOOST_MPL_ASSERT_NOT(pred) \ +BOOST_MPL_AUX_ASSERT_CONSTANT( \ + std::size_t \ + , BOOST_PP_CAT(mpl_assertion_in_line_,BOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ + boost::mpl::assertion_failed( \ + boost::mpl::make_assert_arg< \ + typename boost::mpl::eval_assert_not::type \ + >() \ + ) \ + ) \ + ) \ +/**/ + +#else // BOOST_MPL_ASSERT((pred)) @@ -250,6 +316,8 @@ BOOST_MPL_AUX_ASSERT_CONSTANT( \ /**/ #endif +#endif + // BOOST_MPL_ASSERT_RELATION(x, ==|!=|<=|<|>=|>, y) #if defined(BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES) diff --git a/test/assert.cpp b/test/assert.cpp index facaae7..b20f699 100644 --- a/test/assert.cpp +++ b/test/assert.cpp @@ -71,6 +71,17 @@ struct her } }; +template +struct nested : boost::mpl::true_ { + BOOST_MPL_ASSERT(( boost::is_pointer )); + BOOST_MPL_ASSERT_NOT(( boost::is_same )); + BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +}; + +BOOST_MPL_ASSERT(( nested )); +BOOST_MPL_ASSERT_NOT(( boost::mpl::not_ > )); + int main() { her h;