1
0
forked from boostorg/mpl

Work around VC11 bug when evaluating nested BOOST_MPL_ASSERTs.

[SVN r81027]
This commit is contained in:
Steven Watanabe
2012-10-20 16:43:51 +00:00
parent 7d2a04eea3
commit aa8e43a017
2 changed files with 80 additions and 1 deletions

View File

@@ -34,6 +34,9 @@
#include <boost/config.hpp> // make sure 'size_t' is placed into 'std' #include <boost/config.hpp> // make sure 'size_t' is placed into 'std'
#include <cstddef> #include <cstddef>
#if BOOST_WORKAROUND(BOOST_MSVC, == 1700)
#include <boost/mpl/if.hpp>
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) \ #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) \
|| (BOOST_MPL_CFG_GCC != 0) \ || (BOOST_MPL_CFG_GCC != 0) \
@@ -131,8 +134,38 @@ template< assert_::relations r, long x, long y > struct assert_relation {};
#endif #endif
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1700)
#if !defined(BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER) template<class Pred>
struct extract_assert_pred;
template<class Pred>
struct extract_assert_pred<void(Pred)> { typedef Pred type; };
template<class Pred>
struct eval_assert {
typedef typename extract_assert_pred<Pred>::type P;
typedef typename P::type p_type;
typedef typename ::boost::mpl::if_c<p_type::value,
AUX778076_ASSERT_ARG(assert<false>),
failed ************ P::************
>::type type;
};
template<class Pred>
struct eval_assert_not {
typedef typename extract_assert_pred<Pred>::type P;
typedef typename P::type p_type;
typedef typename ::boost::mpl::if_c<!p_type::value,
AUX778076_ASSERT_ARG(assert<false>),
failed ************ ::boost::mpl::not_<P>::************
>::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< bool > struct assert_arg_pred_impl { typedef int type; };
template<> struct assert_arg_pred_impl<true> { typedef void* type; }; template<> struct assert_arg_pred_impl<true> { typedef void* type; };
@@ -211,6 +244,39 @@ assert_rel_arg( assert_relation<r,x,y> );
BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE
#if BOOST_WORKAROUND(BOOST_MSVC, == 1700)
// BOOST_MPL_ASSERT((pred<x,...>))
#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<false>( \
boost::mpl::make_assert_arg< \
typename boost::mpl::eval_assert<void pred>::type \
>() \
) \
) \
) \
/**/
// BOOST_MPL_ASSERT_NOT((pred<x,...>))
#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<false>( \
boost::mpl::make_assert_arg< \
typename boost::mpl::eval_assert_not<void pred>::type \
>() \
) \
) \
) \
/**/
#else
// BOOST_MPL_ASSERT((pred<x,...>)) // BOOST_MPL_ASSERT((pred<x,...>))
@@ -250,6 +316,8 @@ BOOST_MPL_AUX_ASSERT_CONSTANT( \
/**/ /**/
#endif #endif
#endif
// BOOST_MPL_ASSERT_RELATION(x, ==|!=|<=|<|>=|>, y) // BOOST_MPL_ASSERT_RELATION(x, ==|!=|<=|<|>=|>, y)
#if defined(BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES) #if defined(BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES)

View File

@@ -71,6 +71,17 @@ struct her
} }
}; };
template<class T>
struct nested : boost::mpl::true_ {
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
BOOST_MPL_ASSERT_NOT(( boost::is_same<void,T> ));
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
};
BOOST_MPL_ASSERT(( nested<int> ));
BOOST_MPL_ASSERT_NOT(( boost::mpl::not_<nested<unsigned> > ));
int main() int main()
{ {
her<void> h; her<void> h;