Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 1 | // Copyright David Abrahams 2006. Distributed under the Boost |
| 2 | // Software License, Version 1.0. (See accompanying |
| 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 4 | #ifndef NDNBOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP |
| 5 | # define NDNBOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 6 | |
| 7 | # include <ndnboost/preprocessor/cat.hpp> |
| 8 | # include <ndnboost/concept/detail/backward_compatibility.hpp> |
| 9 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 10 | # ifdef NDNBOOST_OLD_CONCEPT_SUPPORT |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 11 | # include <ndnboost/concept/detail/has_constraints.hpp> |
| 12 | # include <ndnboost/mpl/if.hpp> |
| 13 | # endif |
| 14 | |
| 15 | |
| 16 | namespace ndnboost { namespace concepts { |
| 17 | |
| 18 | |
| 19 | template <class Model> |
| 20 | struct check |
| 21 | { |
| 22 | virtual void failed(Model* x) |
| 23 | { |
| 24 | x->~Model(); |
| 25 | } |
| 26 | }; |
| 27 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 28 | # ifndef NDNBOOST_NO_PARTIAL_SPECIALIZATION |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 29 | struct failed {}; |
| 30 | template <class Model> |
| 31 | struct check<failed ************ Model::************> |
| 32 | { |
| 33 | virtual void failed(Model* x) |
| 34 | { |
| 35 | x->~Model(); |
| 36 | } |
| 37 | }; |
| 38 | # endif |
| 39 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 40 | # ifdef NDNBOOST_OLD_CONCEPT_SUPPORT |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 41 | |
| 42 | namespace detail |
| 43 | { |
| 44 | // No need for a virtual function here, since evaluating |
| 45 | // not_satisfied below will have already instantiated the |
| 46 | // constraints() member. |
| 47 | struct constraint {}; |
| 48 | } |
| 49 | |
| 50 | template <class Model> |
| 51 | struct require |
| 52 | : mpl::if_c< |
| 53 | not_satisfied<Model>::value |
| 54 | , detail::constraint |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 55 | # ifndef NDNBOOST_NO_PARTIAL_SPECIALIZATION |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 56 | , check<Model> |
| 57 | # else |
| 58 | , check<failed ************ Model::************> |
| 59 | # endif |
| 60 | >::type |
| 61 | {}; |
| 62 | |
| 63 | # else |
| 64 | |
| 65 | template <class Model> |
| 66 | struct require |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 67 | # ifndef NDNBOOST_NO_PARTIAL_SPECIALIZATION |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 68 | : check<Model> |
| 69 | # else |
| 70 | : check<failed ************ Model::************> |
| 71 | # endif |
| 72 | {}; |
| 73 | |
| 74 | # endif |
| 75 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 76 | # if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1310) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 77 | |
| 78 | // |
| 79 | // The iterator library sees some really strange errors unless we |
| 80 | // do things this way. |
| 81 | // |
| 82 | template <class Model> |
| 83 | struct require<void(*)(Model)> |
| 84 | { |
| 85 | virtual void failed(Model*) |
| 86 | { |
| 87 | require<Model>(); |
| 88 | } |
| 89 | }; |
| 90 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 91 | # define NDNBOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 92 | enum \ |
| 93 | { \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 94 | NDNBOOST_PP_CAT(boost_concept_check,__LINE__) = \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 95 | sizeof(::ndnboost::concepts::require<ModelFnPtr>) \ |
| 96 | } |
| 97 | |
| 98 | # else // Not vc-7.1 |
| 99 | |
| 100 | template <class Model> |
| 101 | require<Model> |
| 102 | require_(void(*)(Model)); |
| 103 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 104 | # define NDNBOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 105 | enum \ |
| 106 | { \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 107 | NDNBOOST_PP_CAT(boost_concept_check,__LINE__) = \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 108 | sizeof(::ndnboost::concepts::require_((ModelFnPtr)0)) \ |
| 109 | } |
| 110 | |
| 111 | # endif |
| 112 | }} |
| 113 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 114 | #endif // NDNBOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP |