Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 2 | #ifndef NDNBOOST_MPL_ASSERT_HPP_INCLUDED |
| 3 | #define NDNBOOST_MPL_ASSERT_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 4 | |
| 5 | // Copyright Aleksey Gurtovoy 2000-2006 |
| 6 | // |
| 7 | // Distributed under the Boost Software License, Version 1.0. |
| 8 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 9 | // http://www.boost.org/LICENSE_1_0.txt) |
| 10 | // |
| 11 | // See http://www.boost.org/libs/mpl for documentation. |
| 12 | |
| 13 | // $Id: assert.hpp 84442 2013-05-23 14:38:22Z steven_watanabe $ |
| 14 | // $Date: 2013-05-23 07:38:22 -0700 (Thu, 23 May 2013) $ |
| 15 | // $Revision: 84442 $ |
| 16 | |
| 17 | #include <ndnboost/mpl/not.hpp> |
| 18 | #include <ndnboost/mpl/aux_/value_wknd.hpp> |
| 19 | #include <ndnboost/mpl/aux_/nested_type_wknd.hpp> |
| 20 | #include <ndnboost/mpl/aux_/yes_no.hpp> |
| 21 | #include <ndnboost/mpl/aux_/na.hpp> |
| 22 | #include <ndnboost/mpl/aux_/adl_barrier.hpp> |
| 23 | |
| 24 | #include <ndnboost/mpl/aux_/config/nttp.hpp> |
| 25 | #include <ndnboost/mpl/aux_/config/dtp.hpp> |
| 26 | #include <ndnboost/mpl/aux_/config/gcc.hpp> |
| 27 | #include <ndnboost/mpl/aux_/config/msvc.hpp> |
| 28 | #include <ndnboost/mpl/aux_/config/static_constant.hpp> |
| 29 | #include <ndnboost/mpl/aux_/config/pp_counter.hpp> |
| 30 | #include <ndnboost/mpl/aux_/config/workaround.hpp> |
| 31 | |
| 32 | #include <ndnboost/preprocessor/cat.hpp> |
| 33 | |
| 34 | #include <ndnboost/config.hpp> // make sure 'size_t' is placed into 'std' |
| 35 | #include <cstddef> |
| 36 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 37 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1700) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 38 | #include <ndnboost/mpl/if.hpp> |
| 39 | #endif |
| 40 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 41 | #if NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x610)) \ |
| 42 | || (NDNBOOST_MPL_CFG_GCC != 0) \ |
| 43 | || NDNBOOST_WORKAROUND(__IBMCPP__, <= 600) |
| 44 | # define NDNBOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 45 | #endif |
| 46 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 47 | #if NDNBOOST_WORKAROUND(__MWERKS__, < 0x3202) \ |
| 48 | || NDNBOOST_WORKAROUND(__EDG_VERSION__, <= 238) \ |
| 49 | || NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x610)) \ |
| 50 | || NDNBOOST_WORKAROUND(__DMC__, NDNBOOST_TESTED_AT(0x840)) |
| 51 | # define NDNBOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 52 | #endif |
| 53 | |
| 54 | // agurt, 10/nov/06: use enums for Borland (which cannot cope with static constants) |
| 55 | // and GCC (which issues "unused variable" warnings when static constants are used |
| 56 | // at a function scope) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 57 | #if NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x610)) \ |
| 58 | || (NDNBOOST_MPL_CFG_GCC != 0) |
| 59 | # define NDNBOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) enum { expr } |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 60 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 61 | # define NDNBOOST_MPL_AUX_ASSERT_CONSTANT(T, expr) NDNBOOST_STATIC_CONSTANT(T, expr) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 62 | #endif |
| 63 | |
| 64 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 65 | NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 66 | |
| 67 | struct failed {}; |
| 68 | |
| 69 | // agurt, 24/aug/04: MSVC 7.1 workaround here and below: return/accept |
| 70 | // 'assert<false>' by reference; can't apply it unconditionally -- apparently it |
| 71 | // degrades the quality of GCC diagnostics |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 72 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1310) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 73 | # define AUX778076_ASSERT_ARG(x) x& |
| 74 | #else |
| 75 | # define AUX778076_ASSERT_ARG(x) x |
| 76 | #endif |
| 77 | |
| 78 | template< bool C > struct assert { typedef void* type; }; |
| 79 | template<> struct assert<false> { typedef AUX778076_ASSERT_ARG(assert) type; }; |
| 80 | |
| 81 | template< bool C > |
| 82 | int assertion_failed( typename assert<C>::type ); |
| 83 | |
| 84 | template< bool C > |
| 85 | struct assertion |
| 86 | { |
| 87 | static int failed( assert<false> ); |
| 88 | }; |
| 89 | |
| 90 | template<> |
| 91 | struct assertion<true> |
| 92 | { |
| 93 | static int failed( void* ); |
| 94 | }; |
| 95 | |
| 96 | struct assert_ |
| 97 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 98 | #if !defined(NDNBOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 99 | template< typename T1, typename T2 = na, typename T3 = na, typename T4 = na > struct types {}; |
| 100 | #endif |
| 101 | static assert_ const arg; |
| 102 | enum relations { equal = 1, not_equal, greater, greater_equal, less, less_equal }; |
| 103 | }; |
| 104 | |
| 105 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 106 | #if !defined(NDNBOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 107 | |
| 108 | bool operator==( failed, failed ); |
| 109 | bool operator!=( failed, failed ); |
| 110 | bool operator>( failed, failed ); |
| 111 | bool operator>=( failed, failed ); |
| 112 | bool operator<( failed, failed ); |
| 113 | bool operator<=( failed, failed ); |
| 114 | |
| 115 | #if defined(__EDG_VERSION__) |
| 116 | template< bool (*)(failed, failed), long x, long y > struct assert_relation {}; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 117 | # define NDNBOOST_MPL_AUX_ASSERT_RELATION(x, y, r) assert_relation<r,x,y> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 118 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 119 | template< NDNBOOST_MPL_AUX_NTTP_DECL(long, x), NDNBOOST_MPL_AUX_NTTP_DECL(long, y), bool (*)(failed, failed) > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 120 | struct assert_relation {}; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 121 | # define NDNBOOST_MPL_AUX_ASSERT_RELATION(x, y, r) assert_relation<x,y,r> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 122 | #endif |
| 123 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 124 | #else // NDNBOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 125 | |
| 126 | ndnboost::mpl::aux::weighted_tag<1>::type operator==( assert_, assert_ ); |
| 127 | ndnboost::mpl::aux::weighted_tag<2>::type operator!=( assert_, assert_ ); |
| 128 | ndnboost::mpl::aux::weighted_tag<3>::type operator>( assert_, assert_ ); |
| 129 | ndnboost::mpl::aux::weighted_tag<4>::type operator>=( assert_, assert_ ); |
| 130 | ndnboost::mpl::aux::weighted_tag<5>::type operator<( assert_, assert_ ); |
| 131 | ndnboost::mpl::aux::weighted_tag<6>::type operator<=( assert_, assert_ ); |
| 132 | |
| 133 | template< assert_::relations r, long x, long y > struct assert_relation {}; |
| 134 | |
| 135 | #endif |
| 136 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 137 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, >= 1700) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 138 | |
| 139 | template<class Pred> |
| 140 | struct extract_assert_pred; |
| 141 | |
| 142 | template<class Pred> |
| 143 | struct extract_assert_pred<void(Pred)> { typedef Pred type; }; |
| 144 | |
| 145 | template<class Pred> |
| 146 | struct eval_assert { |
| 147 | typedef typename extract_assert_pred<Pred>::type P; |
| 148 | typedef typename P::type p_type; |
| 149 | typedef typename ::ndnboost::mpl::if_c<p_type::value, |
| 150 | AUX778076_ASSERT_ARG(assert<false>), |
| 151 | failed ************ P::************ |
| 152 | >::type type; |
| 153 | }; |
| 154 | |
| 155 | template<class Pred> |
| 156 | struct eval_assert_not { |
| 157 | typedef typename extract_assert_pred<Pred>::type P; |
| 158 | typedef typename P::type p_type; |
| 159 | typedef typename ::ndnboost::mpl::if_c<!p_type::value, |
| 160 | AUX778076_ASSERT_ARG(assert<false>), |
| 161 | failed ************ ::ndnboost::mpl::not_<P>::************ |
| 162 | >::type type; |
| 163 | }; |
| 164 | |
| 165 | template< typename T > |
| 166 | T make_assert_arg(); |
| 167 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 168 | #elif !defined(NDNBOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 169 | |
| 170 | template< bool > struct assert_arg_pred_impl { typedef int type; }; |
| 171 | template<> struct assert_arg_pred_impl<true> { typedef void* type; }; |
| 172 | |
| 173 | template< typename P > struct assert_arg_pred |
| 174 | { |
| 175 | typedef typename P::type p_type; |
| 176 | typedef typename assert_arg_pred_impl< p_type::value >::type type; |
| 177 | }; |
| 178 | |
| 179 | template< typename P > struct assert_arg_pred_not |
| 180 | { |
| 181 | typedef typename P::type p_type; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 182 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( bool, p = !p_type::value ); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 183 | typedef typename assert_arg_pred_impl<p>::type type; |
| 184 | }; |
| 185 | |
| 186 | template< typename Pred > |
| 187 | failed ************ (Pred::************ |
| 188 | assert_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type ) |
| 189 | ); |
| 190 | |
| 191 | template< typename Pred > |
| 192 | failed ************ (ndnboost::mpl::not_<Pred>::************ |
| 193 | assert_not_arg( void (*)(Pred), typename assert_arg_pred_not<Pred>::type ) |
| 194 | ); |
| 195 | |
| 196 | template< typename Pred > |
| 197 | AUX778076_ASSERT_ARG(assert<false>) |
| 198 | assert_arg( void (*)(Pred), typename assert_arg_pred_not<Pred>::type ); |
| 199 | |
| 200 | template< typename Pred > |
| 201 | AUX778076_ASSERT_ARG(assert<false>) |
| 202 | assert_not_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type ); |
| 203 | |
| 204 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 205 | #else // NDNBOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 206 | |
| 207 | template< bool c, typename Pred > struct assert_arg_type_impl |
| 208 | { |
| 209 | typedef failed ************ Pred::* mwcw83_wknd; |
| 210 | typedef mwcw83_wknd ************* type; |
| 211 | }; |
| 212 | |
| 213 | template< typename Pred > struct assert_arg_type_impl<true,Pred> |
| 214 | { |
| 215 | typedef AUX778076_ASSERT_ARG(assert<false>) type; |
| 216 | }; |
| 217 | |
| 218 | template< typename Pred > struct assert_arg_type |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 219 | : assert_arg_type_impl< NDNBOOST_MPL_AUX_VALUE_WKND(NDNBOOST_MPL_AUX_NESTED_TYPE_WKND(Pred))::value, Pred > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 220 | { |
| 221 | }; |
| 222 | |
| 223 | template< typename Pred > |
| 224 | typename assert_arg_type<Pred>::type |
| 225 | assert_arg(void (*)(Pred), int); |
| 226 | |
| 227 | template< typename Pred > |
| 228 | typename assert_arg_type< ndnboost::mpl::not_<Pred> >::type |
| 229 | assert_not_arg(void (*)(Pred), int); |
| 230 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 231 | # if !defined(NDNBOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 232 | template< long x, long y, bool (*r)(failed, failed) > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 233 | typename assert_arg_type_impl< false,NDNBOOST_MPL_AUX_ASSERT_RELATION(x,y,r) >::type |
| 234 | assert_rel_arg( NDNBOOST_MPL_AUX_ASSERT_RELATION(x,y,r) ); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 235 | # else |
| 236 | template< assert_::relations r, long x, long y > |
| 237 | typename assert_arg_type_impl< false,assert_relation<r,x,y> >::type |
| 238 | assert_rel_arg( assert_relation<r,x,y> ); |
| 239 | # endif |
| 240 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 241 | #endif // NDNBOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 242 | |
| 243 | #undef AUX778076_ASSERT_ARG |
| 244 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 245 | NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 246 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 247 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1700) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 248 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 249 | // NDNBOOST_MPL_ASSERT((pred<x,...>)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 250 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 251 | #define NDNBOOST_MPL_ASSERT(pred) \ |
| 252 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 253 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 254 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,NDNBOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 255 | ndnboost::mpl::assertion_failed<false>( \ |
| 256 | ndnboost::mpl::make_assert_arg< \ |
| 257 | typename ndnboost::mpl::eval_assert<void pred>::type \ |
| 258 | >() \ |
| 259 | ) \ |
| 260 | ) \ |
| 261 | ) \ |
| 262 | /**/ |
| 263 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 264 | // NDNBOOST_MPL_ASSERT_NOT((pred<x,...>)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 265 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 266 | #define NDNBOOST_MPL_ASSERT_NOT(pred) \ |
| 267 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 268 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 269 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,NDNBOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 270 | ndnboost::mpl::assertion_failed<false>( \ |
| 271 | ndnboost::mpl::make_assert_arg< \ |
| 272 | typename ndnboost::mpl::eval_assert_not<void pred>::type \ |
| 273 | >() \ |
| 274 | ) \ |
| 275 | ) \ |
| 276 | ) \ |
| 277 | /**/ |
| 278 | |
| 279 | #else |
| 280 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 281 | // NDNBOOST_MPL_ASSERT((pred<x,...>)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 282 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 283 | #define NDNBOOST_MPL_ASSERT(pred) \ |
| 284 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 285 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 286 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,NDNBOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 287 | ndnboost::mpl::assertion_failed<false>( \ |
| 288 | ndnboost::mpl::assert_arg( (void (*) pred)0, 1 ) \ |
| 289 | ) \ |
| 290 | ) \ |
| 291 | ) \ |
| 292 | /**/ |
| 293 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 294 | // NDNBOOST_MPL_ASSERT_NOT((pred<x,...>)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 295 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 296 | #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) |
| 297 | # define NDNBOOST_MPL_ASSERT_NOT(pred) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 298 | enum { \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 299 | NDNBOOST_PP_CAT(mpl_assertion_in_line_,NDNBOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 300 | ndnboost::mpl::assertion<false>::failed( \ |
| 301 | ndnboost::mpl::assert_not_arg( (void (*) pred)0, 1 ) \ |
| 302 | ) \ |
| 303 | ) \ |
| 304 | }\ |
| 305 | /**/ |
| 306 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 307 | # define NDNBOOST_MPL_ASSERT_NOT(pred) \ |
| 308 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 309 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 310 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,NDNBOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 311 | ndnboost::mpl::assertion_failed<false>( \ |
| 312 | ndnboost::mpl::assert_not_arg( (void (*) pred)0, 1 ) \ |
| 313 | ) \ |
| 314 | ) \ |
| 315 | ) \ |
| 316 | /**/ |
| 317 | #endif |
| 318 | |
| 319 | #endif |
| 320 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 321 | // NDNBOOST_MPL_ASSERT_RELATION(x, ==|!=|<=|<|>=|>, y) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 322 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 323 | #if defined(NDNBOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 324 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 325 | # if !defined(NDNBOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 326 | // agurt, 9/nov/06: 'enum' below is a workaround for gcc 4.0.4/4.1.1 bugs #29522 and #29518 |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 327 | # define NDNBOOST_MPL_ASSERT_RELATION_IMPL(counter, x, rel, y) \ |
| 328 | enum { NDNBOOST_PP_CAT(mpl_assert_rel_value,counter) = (x rel y) }; \ |
| 329 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 330 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 331 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,counter) = sizeof( \ |
| 332 | ndnboost::mpl::assertion_failed<NDNBOOST_PP_CAT(mpl_assert_rel_value,counter)>( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 333 | (ndnboost::mpl::failed ************ ( ndnboost::mpl::assert_relation< \ |
| 334 | ndnboost::mpl::assert_::relations( sizeof( \ |
| 335 | ndnboost::mpl::assert_::arg rel ndnboost::mpl::assert_::arg \ |
| 336 | ) ) \ |
| 337 | , x \ |
| 338 | , y \ |
| 339 | >::************)) 0 ) \ |
| 340 | ) \ |
| 341 | ) \ |
| 342 | /**/ |
| 343 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 344 | # define NDNBOOST_MPL_ASSERT_RELATION_IMPL(counter, x, rel, y) \ |
| 345 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 346 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 347 | , NDNBOOST_PP_CAT(mpl_assert_rel,counter) = sizeof( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 348 | ndnboost::mpl::assert_::arg rel ndnboost::mpl::assert_::arg \ |
| 349 | ) \ |
| 350 | ); \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 351 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( bool, NDNBOOST_PP_CAT(mpl_assert_rel_value,counter) = (x rel y) ); \ |
| 352 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 353 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 354 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,counter) = sizeof( \ |
| 355 | ndnboost::mpl::assertion_failed<NDNBOOST_PP_CAT(mpl_assert_rel_value,counter)>( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 356 | ndnboost::mpl::assert_rel_arg( ndnboost::mpl::assert_relation< \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 357 | ndnboost::mpl::assert_::relations(NDNBOOST_PP_CAT(mpl_assert_rel,counter)) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 358 | , x \ |
| 359 | , y \ |
| 360 | >() ) \ |
| 361 | ) \ |
| 362 | ) \ |
| 363 | ) \ |
| 364 | /**/ |
| 365 | # endif |
| 366 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 367 | # define NDNBOOST_MPL_ASSERT_RELATION(x, rel, y) \ |
| 368 | NDNBOOST_MPL_ASSERT_RELATION_IMPL(NDNBOOST_MPL_AUX_PP_COUNTER(), x, rel, y) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 369 | /**/ |
| 370 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 371 | #else // !NDNBOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 372 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 373 | # if defined(NDNBOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER) |
| 374 | # define NDNBOOST_MPL_ASSERT_RELATION(x, rel, y) \ |
| 375 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 376 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 377 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,NDNBOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 378 | ndnboost::mpl::assertion_failed<(x rel y)>( ndnboost::mpl::assert_rel_arg( \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 379 | ndnboost::mpl::NDNBOOST_MPL_AUX_ASSERT_RELATION(x,y,(&ndnboost::mpl::operator rel))() \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 380 | ) ) \ |
| 381 | ) \ |
| 382 | ) \ |
| 383 | /**/ |
| 384 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 385 | # define NDNBOOST_MPL_ASSERT_RELATION(x, rel, y) \ |
| 386 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 387 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 388 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,NDNBOOST_MPL_AUX_PP_COUNTER()) = sizeof( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 389 | ndnboost::mpl::assertion_failed<(x rel y)>( (ndnboost::mpl::failed ************ ( \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 390 | ndnboost::mpl::NDNBOOST_MPL_AUX_ASSERT_RELATION(x,y,(&ndnboost::mpl::operator rel))::************))0 ) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 391 | ) \ |
| 392 | ) \ |
| 393 | /**/ |
| 394 | # endif |
| 395 | |
| 396 | #endif |
| 397 | |
| 398 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 399 | // NDNBOOST_MPL_ASSERT_MSG( (pred<x,...>::value), USER_PROVIDED_MESSAGE, (types<x,...>) ) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 400 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 401 | #if NDNBOOST_WORKAROUND(__MWERKS__, NDNBOOST_TESTED_AT(0x3202)) |
| 402 | # define NDNBOOST_MPL_ASSERT_MSG_IMPL( counter, c, msg, types_ ) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 403 | struct msg; \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 404 | typedef struct NDNBOOST_PP_CAT(msg,counter) : ndnboost::mpl::assert_ \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 405 | { \ |
| 406 | using ndnboost::mpl::assert_::types; \ |
| 407 | static ndnboost::mpl::failed ************ (msg::************ assert_arg()) types_ \ |
| 408 | { return 0; } \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 409 | } NDNBOOST_PP_CAT(mpl_assert_arg,counter); \ |
| 410 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 411 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 412 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,counter) = sizeof( \ |
| 413 | ndnboost::mpl::assertion<(c)>::failed( NDNBOOST_PP_CAT(mpl_assert_arg,counter)::assert_arg() ) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 414 | ) \ |
| 415 | ) \ |
| 416 | /**/ |
| 417 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 418 | # define NDNBOOST_MPL_ASSERT_MSG_IMPL( counter, c, msg, types_ ) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 419 | struct msg; \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 420 | typedef struct NDNBOOST_PP_CAT(msg,counter) : ndnboost::mpl::assert_ \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 421 | { \ |
| 422 | static ndnboost::mpl::failed ************ (msg::************ assert_arg()) types_ \ |
| 423 | { return 0; } \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 424 | } NDNBOOST_PP_CAT(mpl_assert_arg,counter); \ |
| 425 | NDNBOOST_MPL_AUX_ASSERT_CONSTANT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 426 | std::size_t \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 427 | , NDNBOOST_PP_CAT(mpl_assertion_in_line_,counter) = sizeof( \ |
| 428 | ndnboost::mpl::assertion_failed<(c)>( NDNBOOST_PP_CAT(mpl_assert_arg,counter)::assert_arg() ) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 429 | ) \ |
| 430 | ) \ |
| 431 | /**/ |
| 432 | #endif |
| 433 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 434 | #define NDNBOOST_MPL_ASSERT_MSG( c, msg, types_ ) \ |
| 435 | NDNBOOST_MPL_ASSERT_MSG_IMPL( NDNBOOST_MPL_AUX_PP_COUNTER(), c, msg, types_ ) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 436 | /**/ |
| 437 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 438 | #endif // NDNBOOST_MPL_ASSERT_HPP_INCLUDED |