1
2 // (C) Copyright Tobias Schwinger
3 //
4 // Use modification and distribution are subject to the boost Software License,
5 // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
6
7 //------------------------------------------------------------------------------
8
9 #include <boost/mpl/assert.hpp>
10 #include <boost/type_traits/is_same.hpp>
11
12 #include <boost/function_types/function_type.hpp>
13
14 namespace ft = boost::function_types;
15 namespace mpl = boost::mpl;
16
17 template<typename C, typename T>
test_non_cv(T C::*)18 void test_non_cv(T C::*)
19 {
20 BOOST_MPL_ASSERT(( boost::is_same<
21 ft::function_type< mpl::vector<void,int>,
22 ft::tag<ft::non_const,ft::non_volatile> >::type
23 , T
24 >));
25
26 BOOST_MPL_ASSERT(( boost::is_same<
27 ft::function_type< mpl::vector<void,int>, ft::non_const >::type
28 , T
29 >));
30
31 BOOST_MPL_ASSERT(( boost::is_same<
32 ft::function_type< mpl::vector<void,int>, ft::non_volatile >::type
33 , T
34 >));
35
36 BOOST_MPL_ASSERT(( boost::is_same<
37 ft::function_type< mpl::vector<void,int> >::type
38 , T
39 >));
40
41 BOOST_MPL_ASSERT_NOT(( boost::is_same<
42 ft::function_type< mpl::vector<void,int>,
43 ft::tag<ft::const_qualified,ft::non_volatile> >::type
44 , T
45 >));
46
47 BOOST_MPL_ASSERT_NOT(( boost::is_same<
48 ft::function_type< mpl::vector<void,int>, ft::const_qualified >::type
49 , T
50 >));
51
52 BOOST_MPL_ASSERT_NOT(( boost::is_same<
53 ft::function_type< mpl::vector<void,int>,
54 ft::tag<ft::non_const,ft::volatile_qualified> >::type
55 , T
56 >));
57
58 BOOST_MPL_ASSERT_NOT((
59 boost::is_same<
60 ft::function_type< mpl::vector<void,int>, ft::volatile_qualified >::type
61 , T
62 >));
63
64 BOOST_MPL_ASSERT_NOT(( boost::is_same<
65 ft::function_type< mpl::vector<void,int>,
66 ft::tag<ft::const_qualified,ft::volatile_qualified> >::type
67 , T
68 >));
69 }
70
71 template<typename C, typename T>
test_c_non_v(T C::*)72 void test_c_non_v(T C::*)
73 {
74 BOOST_MPL_ASSERT_NOT(( boost::is_same<
75 ft::function_type< mpl::vector<void,int>,
76 ft::tag<ft::non_const,ft::non_volatile> >::type
77 , T
78 >));
79
80 BOOST_MPL_ASSERT_NOT(( boost::is_same<
81 ft::function_type< mpl::vector<void,int>, ft::non_const >::type
82 , T
83 >));
84
85 BOOST_MPL_ASSERT_NOT(( boost::is_same<
86 ft::function_type< mpl::vector<void,int>, ft::non_volatile >::type
87 , T
88 >));
89
90 BOOST_MPL_ASSERT_NOT(( boost::is_same<
91 ft::function_type< mpl::vector<void,int> >::type
92 , T
93 >));
94
95 BOOST_MPL_ASSERT(( boost::is_same<
96 ft::function_type< mpl::vector<void,int>,
97 ft::tag<ft::const_qualified,ft::non_volatile> >::type
98 , T
99 >));
100
101 BOOST_MPL_ASSERT(( boost::is_same<
102 ft::function_type< mpl::vector<void,int>, ft::const_qualified >::type
103 , T
104 >));
105
106 BOOST_MPL_ASSERT_NOT(( boost::is_same<
107 ft::function_type< mpl::vector<void,int>,
108 ft::tag<ft::non_const,ft::volatile_qualified> >::type
109 , T
110 >));
111
112 BOOST_MPL_ASSERT_NOT((
113 boost::is_same<
114 ft::function_type< mpl::vector<void,int>, ft::volatile_qualified >::type
115 , T
116 >));
117
118 BOOST_MPL_ASSERT_NOT(( boost::is_same<
119 ft::function_type< mpl::vector<void,int>,
120 ft::tag<ft::const_qualified,ft::volatile_qualified> >::type
121 , T
122 >));
123 }
124
125 template<typename C, typename T>
test_v_non_c(T C::*)126 void test_v_non_c(T C::*)
127 {
128 BOOST_MPL_ASSERT_NOT(( boost::is_same<
129 ft::function_type< mpl::vector<void,int>,
130 ft::tag<ft::non_const,ft::non_volatile> >::type
131 , T
132 >));
133
134 BOOST_MPL_ASSERT_NOT(( boost::is_same<
135 ft::function_type< mpl::vector<void,int>, ft::non_const >::type
136 , T
137 >));
138
139 BOOST_MPL_ASSERT_NOT(( boost::is_same<
140 ft::function_type< mpl::vector<void,int>, ft::non_volatile >::type
141 , T
142 >));
143
144 BOOST_MPL_ASSERT_NOT(( boost::is_same<
145 ft::function_type< mpl::vector<void,int> >::type
146 , T
147 >));
148
149 BOOST_MPL_ASSERT_NOT(( boost::is_same<
150 ft::function_type< mpl::vector<void,int>,
151 ft::tag<ft::const_qualified,ft::non_volatile> >::type
152 , T
153 >));
154
155 BOOST_MPL_ASSERT_NOT(( boost::is_same<
156 ft::function_type< mpl::vector<void,int>, ft::const_qualified >::type
157 , T
158 >));
159
160 BOOST_MPL_ASSERT(( boost::is_same<
161 ft::function_type< mpl::vector<void,int>,
162 ft::tag<ft::non_const,ft::volatile_qualified> >::type
163 , T
164 >));
165
166 BOOST_MPL_ASSERT((
167 boost::is_same<
168 ft::function_type< mpl::vector<void,int>, ft::volatile_qualified >::type
169 , T
170 >));
171
172 BOOST_MPL_ASSERT_NOT(( boost::is_same<
173 ft::function_type< mpl::vector<void,int>,
174 ft::tag<ft::const_qualified,ft::volatile_qualified> >::type
175 , T
176 >));
177 }
178
179 template<typename C, typename T>
test_cv(T C::*)180 void test_cv(T C::*)
181 {
182 BOOST_MPL_ASSERT_NOT(( boost::is_same<
183 ft::function_type< mpl::vector<void,int>,
184 ft::tag<ft::non_const,ft::non_volatile> >::type
185 , T
186 >));
187
188 BOOST_MPL_ASSERT_NOT(( boost::is_same<
189 ft::function_type< mpl::vector<void,int>, ft::non_const >::type
190 , T
191 >));
192
193 BOOST_MPL_ASSERT_NOT(( boost::is_same<
194 ft::function_type< mpl::vector<void,int>, ft::non_volatile >::type
195 , T
196 >));
197
198 BOOST_MPL_ASSERT_NOT(( boost::is_same<
199 ft::function_type< mpl::vector<void,int> >::type
200 , T
201 >));
202
203 BOOST_MPL_ASSERT_NOT(( boost::is_same<
204 ft::function_type< mpl::vector<void,int>,
205 ft::tag<ft::const_qualified,ft::non_volatile> >::type
206 , T
207 >));
208
209 BOOST_MPL_ASSERT_NOT(( boost::is_same<
210 ft::function_type< mpl::vector<void,int>, ft::const_qualified >::type
211 , T
212 >));
213
214 BOOST_MPL_ASSERT_NOT(( boost::is_same<
215 ft::function_type< mpl::vector<void,int>,
216 ft::tag<ft::non_const,ft::volatile_qualified> >::type
217 , T
218 >));
219
220 BOOST_MPL_ASSERT_NOT((
221 boost::is_same<
222 ft::function_type< mpl::vector<void,int>, ft::volatile_qualified >::type
223 , T
224 >));
225
226 BOOST_MPL_ASSERT(( boost::is_same<
227 ft::function_type< mpl::vector<void,int>,
228 ft::tag<ft::const_qualified,ft::volatile_qualified> >::type
229 , T
230 >));
231 }
232
233
234 struct C
235 {
non_cvC236 void non_cv(int) { }
c_non_vC237 void c_non_v(int) const { }
v_non_cC238 void v_non_c(int) volatile { }
cvC239 void cv(int) const volatile { }
240 };
241
instanitate()242 void instanitate()
243 {
244 test_non_cv(& C::non_cv);
245 test_c_non_v(& C::c_non_v);
246 test_v_non_c(& C::v_non_c);
247 test_cv(& C::cv);
248 }
249
250