1 | // Copyright Daniel Wallin 2006. |
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 | #include <boost/parameter/config.hpp> |
7 | #include <boost/parameter/parameters.hpp> |
8 | #include <boost/parameter/name.hpp> |
9 | #include <boost/parameter/binding.hpp> |
10 | #include "deduced.hpp" |
11 | |
12 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) |
13 | #include <boost/mp11/bind.hpp> |
14 | #include <boost/mp11/utility.hpp> |
15 | #include <type_traits> |
16 | #else |
17 | #include <boost/mpl/bool.hpp> |
18 | #include <boost/mpl/placeholders.hpp> |
19 | #include <boost/mpl/if.hpp> |
20 | #include <boost/type_traits/is_same.hpp> |
21 | #include <boost/type_traits/is_convertible.hpp> |
22 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) |
23 | #include <boost/type_traits/remove_reference.hpp> |
24 | #else |
25 | #include <boost/type_traits/add_lvalue_reference.hpp> |
26 | #endif // Borland workarounds needed |
27 | #endif // BOOST_PARAMETER_CAN_USE_MP11 |
28 | |
29 | namespace test { |
30 | |
31 | BOOST_PARAMETER_NAME(x) |
32 | BOOST_PARAMETER_NAME(y) |
33 | BOOST_PARAMETER_NAME(z) |
34 | } // namespace test |
35 | |
36 | #include <boost/core/lightweight_test.hpp> |
37 | |
38 | int main() |
39 | { |
40 | test::check< |
41 | boost::parameter::parameters< |
42 | test::tag::x |
43 | , boost::parameter::optional< |
44 | boost::parameter::deduced<test::tag::y> |
45 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) |
46 | , boost::mp11::mp_bind< |
47 | std::is_same |
48 | , boost::mp11::_1 |
49 | , boost::mp11::mp_bind< |
50 | test::tag::x::binding_fn |
51 | , boost::mp11::_2 |
52 | > |
53 | > |
54 | #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) |
55 | , boost::mpl::if_< |
56 | boost::is_same< |
57 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) |
58 | boost::mpl::_1 |
59 | , boost::remove_reference< |
60 | boost::parameter::binding< |
61 | boost::mpl::_2 |
62 | , test::tag::x |
63 | > |
64 | > |
65 | #else |
66 | boost::add_lvalue_reference<boost::mpl::_1> |
67 | , boost::parameter::binding<boost::mpl::_2,test::tag::x> |
68 | #endif // Borland workarounds needed |
69 | > |
70 | , boost::mpl::true_ |
71 | , boost::mpl::false_ |
72 | > |
73 | #endif // BOOST_PARAMETER_CAN_USE_MP11 |
74 | > |
75 | > |
76 | >(e: (test::_x = 0, test::_y = 1), args: 0, args: 1); |
77 | |
78 | test::check< |
79 | boost::parameter::parameters< |
80 | test::tag::x |
81 | , boost::parameter::optional< |
82 | boost::parameter::deduced<test::tag::y> |
83 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) |
84 | , boost::mp11::mp_bind< |
85 | std::is_same |
86 | , boost::mp11::_1 |
87 | , boost::mp11::mp_bind< |
88 | test::tag::x::binding_fn |
89 | , boost::mp11::_2 |
90 | > |
91 | > |
92 | #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) |
93 | , boost::mpl::if_< |
94 | boost::is_same< |
95 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) |
96 | boost::mpl::_1 |
97 | , boost::remove_reference< |
98 | boost::parameter::binding< |
99 | boost::mpl::_2 |
100 | , test::tag::x |
101 | > |
102 | > |
103 | #else |
104 | boost::add_lvalue_reference<boost::mpl::_1> |
105 | , boost::parameter::binding<boost::mpl::_2,test::tag::x> |
106 | #endif // Borland workarounds needed |
107 | > |
108 | , boost::mpl::true_ |
109 | , boost::mpl::false_ |
110 | > |
111 | #endif // BOOST_PARAMETER_CAN_USE_MP11 |
112 | > |
113 | > |
114 | >(e: (test::_x = 0U, test::_y = 1U), args: 0U, args: 1U); |
115 | |
116 | test::check< |
117 | boost::parameter::parameters< |
118 | test::tag::x |
119 | , boost::parameter::optional< |
120 | boost::parameter::deduced<test::tag::y> |
121 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) |
122 | , boost::mp11::mp_bind< |
123 | std::is_convertible |
124 | , boost::mp11::_1 |
125 | , boost::mp11::mp_bind_q<test::tag::x,boost::mp11::_2> |
126 | > |
127 | #else |
128 | , boost::mpl::if_< |
129 | boost::is_convertible<boost::mpl::_1,test::tag::x::_> |
130 | , boost::mpl::true_ |
131 | , boost::mpl::false_ |
132 | > |
133 | #endif |
134 | > |
135 | > |
136 | >(e: (test::_x = 0, test::_y = 1), args: 0, args: 1); |
137 | |
138 | test::check< |
139 | boost::parameter::parameters< |
140 | test::tag::x |
141 | , boost::parameter::optional< |
142 | boost::parameter::deduced<test::tag::y> |
143 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) |
144 | , boost::mp11::mp_bind< |
145 | std::is_convertible |
146 | , boost::mp11::_1 |
147 | , boost::mp11::mp_bind_q<test::tag::x,boost::mp11::_2> |
148 | > |
149 | #else |
150 | , boost::mpl::if_< |
151 | boost::is_convertible<boost::mpl::_1,test::tag::x::_1> |
152 | , boost::mpl::true_ |
153 | , boost::mpl::false_ |
154 | > |
155 | #endif |
156 | > |
157 | > |
158 | >(e: (test::_x = 0U, test::_y = 1U), args: 0U, args: 1U); |
159 | |
160 | return boost::report_errors(); |
161 | } |
162 | |
163 | |