1// Copyright David Abrahams, Daniel Wallin 2003.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef BOOST_PARAMETER_AUX_PACK_SATISFIES_HPP
7#define BOOST_PARAMETER_AUX_PACK_SATISFIES_HPP
8
9#include <boost/parameter/config.hpp>
10
11#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
12#include <boost/parameter/aux_/arg_list.hpp>
13#include <boost/parameter/aux_/augment_predicate.hpp>
14#include <boost/parameter/aux_/void.hpp>
15#include <boost/mpl/eval_if.hpp>
16#include <boost/mpl/apply_wrap.hpp>
17#include <boost/type_traits/is_same.hpp>
18#else // !BOOST_WORKAROUND(BOOST_MSVC, == 1310)
19#if defined(BOOST_PARAMETER_CAN_USE_MP11)
20#include <boost/mp11/integral.hpp>
21#else
22#include <boost/mpl/bool.hpp>
23#endif
24#include <boost/parameter/aux_/yesno.hpp>
25#include <boost/parameter/aux_/preprocessor/nullptr.hpp>
26#endif // MSVC-7.1 workarounds needed
27
28namespace boost { namespace parameter { namespace aux {
29
30#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
31 template <typename ArgList, typename ParameterRequirements, typename Bound>
32 struct satisfies_impl
33 : ::boost::parameter::aux::augment_predicate<
34 typename ParameterRequirements::predicate
35 , typename ArgList::reference
36 , typename ArgList::key_type
37 , Bound
38 , ArgList
39 >
40 {
41 };
42#endif
43
44 // Returns mpl::true_ iff the given ParameterRequirements are satisfied by
45 // ArgList.
46 template <typename ArgList, typename ParameterRequirements>
47#if defined(BOOST_PARAMETER_CAN_USE_MP11)
48 using satisfies = ::boost::mp11::mp_bool<
49 sizeof(
50 ::boost::parameter::aux::to_yesno(
51 ArgList::satisfies(
52 static_cast<ParameterRequirements*>(
53 BOOST_PARAMETER_AUX_PP_NULLPTR
54 )
55 , static_cast<ArgList*>(BOOST_PARAMETER_AUX_PP_NULLPTR)
56 )
57 )
58 ) == sizeof(::boost::parameter::aux::yes_tag)
59 >;
60#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
61 class satisfies
62 {
63#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
64 // VC7.1 can't handle the sizeof() implementation below,
65 // so we use this instead.
66 typedef typename ::boost::mpl::apply_wrap3<
67 typename ArgList::binding
68 , typename ParameterRequirements::keyword
69 , ::boost::parameter::void_
70 , ::boost::mpl::false_
71 >::type _bound;
72
73 public:
74 typedef typename ::boost::mpl::eval_if<
75 ::boost::is_same<_bound,::boost::parameter::void_>
76 , typename ParameterRequirements::has_default
77 , ::boost::mpl::eval_if<
78 ::boost::is_same<
79 ArgList
80 , ::boost::parameter::aux::empty_arg_list
81 >
82 , ::boost::mpl::false_
83 , ::boost::parameter::aux::satisfies_impl<
84 ArgList
85 , ParameterRequirements
86 , _bound
87 >
88 >
89 >::type type;
90#else // !BOOST_WORKAROUND(BOOST_MSVC, == 1310)
91 BOOST_STATIC_CONSTANT(
92 bool, _value = (
93 sizeof(
94 ::boost::parameter::aux::to_yesno(
95 ArgList::satisfies(
96 static_cast<ParameterRequirements*>(
97 BOOST_PARAMETER_AUX_PP_NULLPTR
98 )
99 , static_cast<ArgList*>(BOOST_PARAMETER_AUX_PP_NULLPTR)
100 )
101 )
102 ) == sizeof(::boost::parameter::aux::yes_tag)
103 )
104 );
105
106 public:
107 typedef ::boost::mpl::bool_<
108 ::boost::parameter::aux
109 ::satisfies<ArgList,ParameterRequirements>::_value
110 > type;
111#endif // MSVC-7.1 workarounds needed
112 };
113#endif // BOOST_PARAMETER_CAN_USE_MP11
114}}} // namespace boost::parameter::aux
115
116#include <boost/parameter/aux_/pack/as_parameter_requirements.hpp>
117
118namespace boost { namespace parameter { namespace aux {
119
120 // Returns mpl::true_ if the requirements of the given ParameterSpec
121 // are satisfied by ArgList.
122 template <typename ArgList, typename ParameterSpec>
123#if defined(BOOST_PARAMETER_CAN_USE_MP11)
124 using satisfies_requirements_of = ::boost::parameter::aux::satisfies<
125 ArgList
126 , typename ::boost::parameter::aux
127 ::as_parameter_requirements<ParameterSpec>::type
128 >;
129#else
130 struct satisfies_requirements_of
131 : ::boost::parameter::aux::satisfies<
132 ArgList
133 , typename ::boost::parameter::aux
134 ::as_parameter_requirements<ParameterSpec>::type
135 >::type
136 {
137 };
138#endif // BOOST_PARAMETER_CAN_USE_MP11
139}}} // namespace boost::parameter::aux
140
141#endif // include guard
142
143

source code of boost/libs/parameter/include/boost/parameter/aux_/pack/satisfies.hpp