blob: 8002ff887052a2b3435cea3f30877c92cd1ac215 [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// 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 Thompson2491bd62013-10-15 17:10:24 -07004#ifndef NDNBOOST_CONCEPT_CHECK_MSVC_NDNBOOST_DWA2006429_HPP
5# define NDNBOOST_CONCEPT_CHECK_MSVC_NDNBOOST_DWA2006429_HPP
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07006
7# include <ndnboost/preprocessor/cat.hpp>
8# include <ndnboost/concept/detail/backward_compatibility.hpp>
9
Jeff Thompson3d613fd2013-10-15 15:39:04 -070010# ifdef NDNBOOST_OLD_CONCEPT_SUPPORT
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070011# include <ndnboost/concept/detail/has_constraints.hpp>
12# include <ndnboost/mpl/if.hpp>
13# endif
14
15
16namespace ndnboost { namespace concepts {
17
18
19template <class Model>
20struct check
21{
22 virtual void failed(Model* x)
23 {
24 x->~Model();
25 }
26};
27
Jeff Thompson3d613fd2013-10-15 15:39:04 -070028# ifndef NDNBOOST_NO_PARTIAL_SPECIALIZATION
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070029struct failed {};
30template <class Model>
31struct check<failed ************ Model::************>
32{
33 virtual void failed(Model* x)
34 {
35 x->~Model();
36 }
37};
38# endif
39
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040# ifdef NDNBOOST_OLD_CONCEPT_SUPPORT
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070041
42namespace 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
50template <class Model>
51struct require
52 : mpl::if_c<
53 not_satisfied<Model>::value
54 , detail::constraint
Jeff Thompson3d613fd2013-10-15 15:39:04 -070055# ifndef NDNBOOST_NO_PARTIAL_SPECIALIZATION
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070056 , check<Model>
57# else
58 , check<failed ************ Model::************>
59# endif
60 >::type
61{};
62
63# else
64
65template <class Model>
66struct require
Jeff Thompson3d613fd2013-10-15 15:39:04 -070067# ifndef NDNBOOST_NO_PARTIAL_SPECIALIZATION
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070068 : check<Model>
69# else
70 : check<failed ************ Model::************>
71# endif
72{};
73
74# endif
75
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076# if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1310)
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070077
78//
79// The iterator library sees some really strange errors unless we
80// do things this way.
81//
82template <class Model>
83struct require<void(*)(Model)>
84{
85 virtual void failed(Model*)
86 {
87 require<Model>();
88 }
89};
90
Jeff Thompson3d613fd2013-10-15 15:39:04 -070091# define NDNBOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070092enum \
93{ \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070094 NDNBOOST_PP_CAT(boost_concept_check,__LINE__) = \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070095 sizeof(::ndnboost::concepts::require<ModelFnPtr>) \
96}
97
98# else // Not vc-7.1
99
100template <class Model>
101require<Model>
102require_(void(*)(Model));
103
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700104# define NDNBOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700105enum \
106{ \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700107 NDNBOOST_PP_CAT(boost_concept_check,__LINE__) = \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700108 sizeof(::ndnboost::concepts::require_((ModelFnPtr)0)) \
109}
110
111# endif
112}}
113
Jeff Thompson2491bd62013-10-15 17:10:24 -0700114#endif // NDNBOOST_CONCEPT_CHECK_MSVC_NDNBOOST_DWA2006429_HPP