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 | 2491bd6 | 2013-10-15 17:10:24 -0700 | [diff] [blame^] | 4 | #ifndef NDNBOOST_CONCEPT_DETAIL_GENERAL_NDNBOOST_DWA2006429_HPP |
| 5 | # define NDNBOOST_CONCEPT_DETAIL_GENERAL_NDNBOOST_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 | // This implementation works on Comeau and GCC, all the way back to |
| 16 | // 2.95 |
| 17 | namespace ndnboost { namespace concepts { |
| 18 | |
| 19 | template <class ModelFn> |
| 20 | struct requirement_; |
| 21 | |
| 22 | namespace detail |
| 23 | { |
| 24 | template <void(*)()> struct instantiate {}; |
| 25 | } |
| 26 | |
| 27 | template <class Model> |
| 28 | struct requirement |
| 29 | { |
| 30 | static void failed() { ((Model*)0)->~Model(); } |
| 31 | }; |
| 32 | |
| 33 | struct failed {}; |
| 34 | |
| 35 | template <class Model> |
| 36 | struct requirement<failed ************ Model::************> |
| 37 | { |
| 38 | static void failed() { ((Model*)0)->~Model(); } |
| 39 | }; |
| 40 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 41 | # ifdef NDNBOOST_OLD_CONCEPT_SUPPORT |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 42 | |
| 43 | template <class Model> |
| 44 | struct constraint |
| 45 | { |
| 46 | static void failed() { ((Model*)0)->constraints(); } |
| 47 | }; |
| 48 | |
| 49 | template <class Model> |
| 50 | struct requirement_<void(*)(Model)> |
| 51 | : mpl::if_< |
| 52 | concepts::not_satisfied<Model> |
| 53 | , constraint<Model> |
| 54 | , requirement<failed ************ Model::************> |
| 55 | >::type |
| 56 | {}; |
| 57 | |
| 58 | # else |
| 59 | |
| 60 | // For GCC-2.x, these can't have exactly the same name |
| 61 | template <class Model> |
| 62 | struct requirement_<void(*)(Model)> |
| 63 | : requirement<failed ************ Model::************> |
| 64 | {}; |
| 65 | |
| 66 | # endif |
| 67 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 68 | # define NDNBOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 69 | typedef ::ndnboost::concepts::detail::instantiate< \ |
| 70 | &::ndnboost::concepts::requirement_<ModelFnPtr>::failed> \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 71 | NDNBOOST_PP_CAT(boost_concept_check,__LINE__) |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 72 | |
| 73 | }} |
| 74 | |
Jeff Thompson | 2491bd6 | 2013-10-15 17:10:24 -0700 | [diff] [blame^] | 75 | #endif // NDNBOOST_CONCEPT_DETAIL_GENERAL_NDNBOOST_DWA2006429_HPP |