Chris@16
|
1 // Copyright David Abrahams 2005. Distributed under the Boost
|
Chris@16
|
2 // Software License, Version 1.0. (See accompanying
|
Chris@16
|
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
4 #ifndef BOOST_PARAMETER_BINDING_DWA200558_HPP
|
Chris@16
|
5 # define BOOST_PARAMETER_BINDING_DWA200558_HPP
|
Chris@16
|
6
|
Chris@16
|
7 # include <boost/mpl/apply.hpp>
|
Chris@16
|
8 # include <boost/mpl/assert.hpp>
|
Chris@16
|
9 # include <boost/mpl/and.hpp>
|
Chris@16
|
10 # include <boost/parameter/aux_/result_of0.hpp>
|
Chris@16
|
11 # include <boost/parameter/aux_/void.hpp>
|
Chris@16
|
12 # include <boost/type_traits/is_same.hpp>
|
Chris@16
|
13
|
Chris@16
|
14 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
Chris@16
|
15 # include <boost/mpl/eval_if.hpp>
|
Chris@16
|
16 # endif
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost { namespace parameter {
|
Chris@16
|
19
|
Chris@16
|
20 // A metafunction that, given an argument pack, returns the type of
|
Chris@16
|
21 // the parameter identified by the given keyword. If no such
|
Chris@16
|
22 // parameter has been specified, returns Default
|
Chris@16
|
23
|
Chris@16
|
24 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
Chris@16
|
25 || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
Chris@16
|
26 template <class Parameters, class Keyword, class Default>
|
Chris@16
|
27 struct binding0
|
Chris@16
|
28 {
|
Chris@16
|
29 typedef typename mpl::apply_wrap3<
|
Chris@16
|
30 typename Parameters::binding,Keyword,Default,mpl::true_
|
Chris@16
|
31 >::type type;
|
Chris@16
|
32
|
Chris@16
|
33 BOOST_MPL_ASSERT_NOT((
|
Chris@16
|
34 mpl::and_<
|
Chris@16
|
35 is_same<Default, void_>
|
Chris@16
|
36 , is_same<type, void_>
|
Chris@16
|
37 >
|
Chris@16
|
38 ));
|
Chris@16
|
39 };
|
Chris@16
|
40 # endif
|
Chris@16
|
41
|
Chris@16
|
42 template <class Parameters, class Keyword, class Default = void_>
|
Chris@16
|
43 # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
Chris@16
|
44 struct binding
|
Chris@16
|
45 # else
|
Chris@16
|
46 struct binding_eti
|
Chris@16
|
47 # endif
|
Chris@16
|
48 {
|
Chris@16
|
49 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
Chris@16
|
50 || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
Chris@16
|
51 typedef typename mpl::eval_if<
|
Chris@16
|
52 mpl::is_placeholder<Parameters>
|
Chris@16
|
53 , mpl::identity<int>
|
Chris@16
|
54 , binding0<Parameters,Keyword,Default>
|
Chris@16
|
55 >::type type;
|
Chris@16
|
56 # else
|
Chris@16
|
57 typedef typename mpl::apply_wrap3<
|
Chris@16
|
58 typename Parameters::binding,Keyword,Default,mpl::true_
|
Chris@16
|
59 >::type type;
|
Chris@16
|
60
|
Chris@16
|
61 BOOST_MPL_ASSERT_NOT((
|
Chris@16
|
62 mpl::and_<
|
Chris@16
|
63 is_same<Default, void_>
|
Chris@16
|
64 , is_same<type, void_>
|
Chris@16
|
65 >
|
Chris@16
|
66 ));
|
Chris@16
|
67 # endif
|
Chris@16
|
68
|
Chris@16
|
69 # if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
Chris@16
|
70 BOOST_MPL_AUX_LAMBDA_SUPPORT(3,binding,(Parameters,Keyword,Default))
|
Chris@16
|
71 # endif
|
Chris@16
|
72 };
|
Chris@16
|
73
|
Chris@16
|
74 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
Chris@16
|
75 template <class Parameters, class Keyword, class Default = void_>
|
Chris@16
|
76 struct binding
|
Chris@16
|
77 {
|
Chris@16
|
78 typedef typename mpl::eval_if<
|
Chris@16
|
79 is_same<Parameters, int>
|
Chris@16
|
80 , mpl::identity<int>
|
Chris@16
|
81 , binding_eti<Parameters, Keyword, Default>
|
Chris@16
|
82 >::type type;
|
Chris@16
|
83
|
Chris@16
|
84 BOOST_MPL_AUX_LAMBDA_SUPPORT(3,binding,(Parameters,Keyword,Default))
|
Chris@16
|
85 };
|
Chris@16
|
86 # endif
|
Chris@16
|
87
|
Chris@16
|
88 // A metafunction that, given an argument pack, returns the type of
|
Chris@16
|
89 // the parameter identified by the given keyword. If no such
|
Chris@16
|
90 // parameter has been specified, returns the type returned by invoking
|
Chris@16
|
91 // DefaultFn
|
Chris@16
|
92 template <class Parameters, class Keyword, class DefaultFn>
|
Chris@16
|
93 struct lazy_binding
|
Chris@16
|
94 {
|
Chris@16
|
95 typedef typename mpl::apply_wrap3<
|
Chris@16
|
96 typename Parameters::binding
|
Chris@16
|
97 , Keyword
|
Chris@16
|
98 , typename aux::result_of0<DefaultFn>::type
|
Chris@16
|
99 , mpl::true_
|
Chris@16
|
100 >::type type;
|
Chris@16
|
101 };
|
Chris@16
|
102
|
Chris@16
|
103
|
Chris@16
|
104 }} // namespace boost::parameter
|
Chris@16
|
105
|
Chris@16
|
106 #endif // BOOST_PARAMETER_BINDING_DWA200558_HPP
|