1 | // Boost.Units - A C++ library for zero-overhead dimensional analysis and |
2 | // unit/quantity manipulation and conversion |
3 | // |
4 | // Copyright (C) 2003-2008 Matthias Christian Schabel |
5 | // Copyright (C) 2008 Steven Watanabe |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. (See |
8 | // accompanying file LICENSE_1_0.txt or copy at |
9 | // http://www.boost.org/LICENSE_1_0.txt) |
10 | |
11 | // $Id: lambda.hpp 27 2008-06-16 14:50:58Z maehne $ |
12 | |
13 | #ifndef BOOST_UNITS_LAMBDA_HPP |
14 | #define BOOST_UNITS_LAMBDA_HPP |
15 | |
16 | |
17 | //////////////////////////////////////////////////////////////////////// |
18 | /// |
19 | /// \file lambda.hpp |
20 | /// |
21 | /// \brief Definitions to ease the usage of Boost.Units' quantity, |
22 | /// unit, and absolute types in functors created with the |
23 | /// Boost.Lambda library. |
24 | /// |
25 | /// \author Torsten Maehne |
26 | /// \date 2008-06-16 |
27 | /// |
28 | /// Boost.Lambda's return type deduction system is extented to make |
29 | /// use of Boost.Units' typeof_helper trait classes for Boost.Units' |
30 | /// quantity, absolute, and unit template classes. |
31 | /// |
32 | //////////////////////////////////////////////////////////////////////// |
33 | |
34 | |
35 | #include <boost/lambda/lambda.hpp> |
36 | #include <boost/units/units_fwd.hpp> |
37 | #include <boost/units/detail/dimensionless_unit.hpp> |
38 | #include <boost/units/operators.hpp> |
39 | |
40 | namespace boost { |
41 | |
42 | namespace lambda { |
43 | |
44 | /// Partial specialization of return type trait for action |
45 | /// unit<Dim, System> * Y. |
46 | template<typename System, typename Dim, typename Y> |
47 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
48 | boost::units::unit<Dim, System>, |
49 | Y > { |
50 | typedef typename boost::units::multiply_typeof_helper< |
51 | boost::units::unit<Dim, System>, Y >::type type; |
52 | }; |
53 | |
54 | } // namespace lambda |
55 | |
56 | namespace units { |
57 | |
58 | template<typename System, typename Dim, typename Arg> |
59 | struct multiply_typeof_helper<boost::units::unit<Dim, System>, boost::lambda::lambda_functor<Arg> > { |
60 | typedef boost::lambda::lambda_functor< |
61 | boost::lambda::lambda_functor_base< |
62 | boost::lambda::arithmetic_action<boost::lambda::multiply_action>, |
63 | tuple<typename boost::lambda::const_copy_argument<const boost::units::unit<Dim, System> >::type, boost::lambda::lambda_functor<Arg> > |
64 | > |
65 | > type; |
66 | }; |
67 | |
68 | /// Disambiguating overload for action |
69 | /// unit<Dim, System> * lambda_functor<Arg> |
70 | /// based on \<boost/lambda/detail/operators.hpp\>. |
71 | template<typename System, typename Dim, typename Arg> |
72 | inline const typename multiply_typeof_helper<boost::units::unit<Dim, System>, boost::lambda::lambda_functor<Arg> >::type |
73 | operator*(const boost::units::unit<Dim, System>& a, |
74 | const boost::lambda::lambda_functor<Arg>& b) { |
75 | return typename multiply_typeof_helper<boost::units::unit<Dim, System>, boost::lambda::lambda_functor<Arg> >::type::inherited |
76 | (tuple<typename boost::lambda::const_copy_argument<const boost::units::unit<Dim, System> >::type, |
77 | boost::lambda::lambda_functor<Arg> > |
78 | (a, b)); |
79 | } |
80 | |
81 | } // namespace units |
82 | |
83 | namespace lambda { |
84 | |
85 | /// Partial specialization of return type trait for action |
86 | /// unit<Dim, System> / Y. |
87 | template<typename System, typename Dim, typename Y> |
88 | struct plain_return_type_2<arithmetic_action<divide_action>, |
89 | boost::units::unit<Dim, System>, |
90 | Y > { |
91 | typedef typename boost::units::divide_typeof_helper< |
92 | boost::units::unit<Dim, System>, Y >::type type; |
93 | }; |
94 | |
95 | } // namespace lambda |
96 | |
97 | namespace units { |
98 | |
99 | template<typename System, typename Dim, typename Arg> |
100 | struct divide_typeof_helper<boost::units::unit<Dim, System>, boost::lambda::lambda_functor<Arg> > { |
101 | typedef boost::lambda::lambda_functor< |
102 | boost::lambda::lambda_functor_base< |
103 | boost::lambda::arithmetic_action<boost::lambda::divide_action>, |
104 | tuple<typename boost::lambda::const_copy_argument<const boost::units::unit<Dim, System> >::type, boost::lambda::lambda_functor<Arg> > |
105 | > |
106 | > type; |
107 | }; |
108 | |
109 | /// Disambiguating overload for action |
110 | /// unit<Dim, System> / lambda_functor<Arg> |
111 | /// based on \<boost/lambda/detail/operators.hpp\>. |
112 | template<typename System, typename Dim, typename Arg> |
113 | inline const typename divide_typeof_helper<boost::units::unit<Dim, System>, boost::lambda::lambda_functor<Arg> >::type |
114 | operator/(const boost::units::unit<Dim, System>& a, |
115 | const boost::lambda::lambda_functor<Arg>& b) { |
116 | return typename divide_typeof_helper<boost::units::unit<Dim, System>, boost::lambda::lambda_functor<Arg> >::type::inherited |
117 | (tuple<typename boost::lambda::const_copy_argument<const boost::units::unit<Dim, System> >::type, |
118 | boost::lambda::lambda_functor<Arg> > |
119 | (a, b)); |
120 | } |
121 | |
122 | } // namespace units |
123 | |
124 | namespace lambda { |
125 | |
126 | /// Partial specialization of return type trait for action |
127 | /// Y * unit<Dim, System>. |
128 | template<typename System, typename Dim, typename Y> |
129 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
130 | Y, |
131 | boost::units::unit<Dim, System> > { |
132 | typedef typename boost::units::multiply_typeof_helper< |
133 | Y, boost::units::unit<Dim, System> >::type type; |
134 | }; |
135 | |
136 | } // namespace lambda |
137 | |
138 | namespace units { |
139 | |
140 | template<typename System, typename Dim, typename Arg> |
141 | struct multiply_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::unit<Dim, System> > { |
142 | typedef boost::lambda::lambda_functor< |
143 | boost::lambda::lambda_functor_base< |
144 | boost::lambda::arithmetic_action<boost::lambda::multiply_action>, |
145 | tuple<boost::lambda::lambda_functor<Arg>, typename boost::lambda::const_copy_argument<const boost::units::unit<Dim, System> >::type> |
146 | > |
147 | > type; |
148 | }; |
149 | |
150 | /// Disambiguating overload for action |
151 | /// lambda_functor<Arg> * unit<Dim, System> |
152 | /// based on \<boost/lambda/detail/operators.hpp\>. |
153 | template<typename System, typename Dim, typename Arg> |
154 | inline const typename multiply_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::unit<Dim, System> >::type |
155 | operator*(const boost::lambda::lambda_functor<Arg>& a, |
156 | const boost::units::unit<Dim, System>& b) { |
157 | return typename multiply_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::unit<Dim, System> >::type::inherited |
158 | (tuple<boost::lambda::lambda_functor<Arg>, |
159 | typename boost::lambda::const_copy_argument<const boost::units::unit<Dim, System> >::type> |
160 | (a, b)); |
161 | } |
162 | |
163 | } // namespace units |
164 | |
165 | namespace lambda { |
166 | |
167 | /// Partial specialization of return type trait for action |
168 | /// Y / unit<Dim, System>. |
169 | template<typename System, typename Dim, typename Y> |
170 | struct plain_return_type_2<arithmetic_action<divide_action>, |
171 | Y, |
172 | boost::units::unit<Dim, System> > { |
173 | typedef typename boost::units::divide_typeof_helper< |
174 | Y, boost::units::unit<Dim, System> >::type type; |
175 | }; |
176 | |
177 | } // namespace lambda |
178 | |
179 | namespace units { |
180 | |
181 | template<typename System, typename Dim, typename Arg> |
182 | struct divide_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::unit<Dim, System> > { |
183 | typedef boost::lambda::lambda_functor< |
184 | boost::lambda::lambda_functor_base< |
185 | boost::lambda::arithmetic_action<boost::lambda::divide_action>, |
186 | tuple<boost::lambda::lambda_functor<Arg>, typename boost::lambda::const_copy_argument<const boost::units::unit<Dim, System> >::type> |
187 | > |
188 | > type; |
189 | }; |
190 | |
191 | /// Disambiguating overload for action |
192 | /// lambda_functor<Arg> / unit<Dim, System> |
193 | /// based on \<boost/lambda/detail/operators.hpp\>. |
194 | template<typename System, typename Dim, typename Arg> |
195 | inline const typename divide_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::unit<Dim, System> >::type |
196 | operator/(const boost::lambda::lambda_functor<Arg>& a, |
197 | const boost::units::unit<Dim, System>& b) { |
198 | return typename divide_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::unit<Dim, System> >::type::inherited |
199 | (tuple<boost::lambda::lambda_functor<Arg>, |
200 | typename boost::lambda::const_copy_argument<const boost::units::unit<Dim, System> >::type> |
201 | (a, b)); |
202 | } |
203 | |
204 | } // namespace units |
205 | |
206 | namespace lambda { |
207 | |
208 | /// Partial specialization of return type trait for action |
209 | /// quantity<Unit, X> * X. |
210 | template<typename Unit, typename X> |
211 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
212 | boost::units::quantity<Unit, X>, |
213 | X> { |
214 | typedef typename boost::units::multiply_typeof_helper< |
215 | boost::units::quantity<Unit, X>, X>::type type; |
216 | }; |
217 | |
218 | /// Partial specialization of return type trait for action |
219 | /// X * quantity<Unit, X>. |
220 | template<typename Unit, typename X> |
221 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
222 | X, |
223 | boost::units::quantity<Unit, X> > { |
224 | typedef typename boost::units::multiply_typeof_helper< |
225 | X, boost::units::quantity<Unit, X> >::type type; |
226 | }; |
227 | |
228 | /// Partial specialization of return type trait for action |
229 | /// quantity<Unit, X> / X. |
230 | template<typename Unit, typename X> |
231 | struct plain_return_type_2<arithmetic_action<divide_action>, |
232 | boost::units::quantity<Unit, X>, |
233 | X> { |
234 | typedef typename boost::units::divide_typeof_helper< |
235 | boost::units::quantity<Unit, X>, X>::type type; |
236 | }; |
237 | |
238 | /// Partial specialization of return type trait for action |
239 | /// X / quantity<Unit, X>. |
240 | template<typename Unit, typename X> |
241 | struct plain_return_type_2<arithmetic_action<divide_action>, |
242 | X, |
243 | boost::units::quantity<Unit, X> > { |
244 | typedef typename boost::units::divide_typeof_helper< |
245 | X, boost::units::quantity<Unit, X> >::type type; |
246 | }; |
247 | |
248 | /// Partial specialization of return type trait for action |
249 | /// unit<Dim1, System1> * quantity<Unit2, Y>. |
250 | template<typename System1, typename Dim1, typename Unit2, typename Y> |
251 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
252 | boost::units::unit<Dim1, System1>, |
253 | boost::units::quantity<Unit2, Y> > { |
254 | typedef typename boost::units::multiply_typeof_helper< |
255 | boost::units::unit<Dim1, System1>, |
256 | boost::units::quantity<Unit2, Y> >::type type; |
257 | }; |
258 | |
259 | /// Partial specialization of return type trait for action |
260 | /// unit<Dim1, System1> / quantity<Unit2, Y>. |
261 | template<typename System1, typename Dim1, typename Unit2, typename Y> |
262 | struct plain_return_type_2<arithmetic_action<divide_action>, |
263 | boost::units::unit<Dim1, System1>, |
264 | boost::units::quantity<Unit2, Y> > { |
265 | typedef typename boost::units::divide_typeof_helper< |
266 | boost::units::unit<Dim1, System1>, |
267 | boost::units::quantity<Unit2, Y> >::type type; |
268 | }; |
269 | |
270 | /// Partial specialization of return type trait for action |
271 | /// quantity<Unit1, Y> * unit<Dim2, System2>. |
272 | template<typename Unit1, typename Y, typename System2, typename Dim2> |
273 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
274 | boost::units::quantity<Unit1, Y>, |
275 | boost::units::unit<Dim2, System2> > { |
276 | typedef typename boost::units::multiply_typeof_helper< |
277 | boost::units::quantity<Unit1, Y>, |
278 | boost::units::unit<Dim2, System2> >::type type; |
279 | }; |
280 | |
281 | /// Partial specialization of return type trait for action |
282 | /// quantity<Unit1, Y> / unit<Dim2, System2>. |
283 | template<typename Unit1, typename Y, typename System2, typename Dim2> |
284 | struct plain_return_type_2<arithmetic_action<divide_action>, |
285 | boost::units::quantity<Unit1, Y>, |
286 | boost::units::unit<Dim2, System2> > { |
287 | typedef typename boost::units::divide_typeof_helper< |
288 | boost::units::quantity<Unit1, Y>, |
289 | boost::units::unit<Dim2, System2> >::type type; |
290 | }; |
291 | |
292 | /// Partial specialization of return type trait for action |
293 | /// +quantity<Unit, Y>. |
294 | template<typename Unit, typename Y> |
295 | struct plain_return_type_1<unary_arithmetic_action<plus_action>, |
296 | boost::units::quantity<Unit, Y> > { |
297 | typedef typename boost::units::unary_plus_typeof_helper< |
298 | boost::units::quantity<Unit, Y> >::type type; |
299 | }; |
300 | |
301 | /// Partial specialization of return type trait for action |
302 | /// -quantity<Unit, Y>. |
303 | template<typename Unit, typename Y> |
304 | struct plain_return_type_1<unary_arithmetic_action<minus_action>, |
305 | boost::units::quantity<Unit, Y> > { |
306 | typedef typename boost::units::unary_minus_typeof_helper< |
307 | boost::units::quantity<Unit, Y> >::type type; |
308 | }; |
309 | |
310 | /// Partial specialization of return type trait for action |
311 | /// quantity<Unit1, X> + quantity<Unit2, Y>. |
312 | template<typename Unit1, typename X, typename Unit2, typename Y> |
313 | struct plain_return_type_2<arithmetic_action<plus_action>, |
314 | boost::units::quantity<Unit1, X>, |
315 | boost::units::quantity<Unit2, Y> > { |
316 | typedef typename boost::units::add_typeof_helper< |
317 | boost::units::quantity<Unit1, X>, |
318 | boost::units::quantity<Unit2, Y> >::type type; |
319 | }; |
320 | |
321 | /// Partial specialization of return type trait for action |
322 | /// quantity<dimensionless, X> + Y. |
323 | template<typename System, typename X, typename Y> |
324 | struct plain_return_type_2<arithmetic_action<plus_action>, |
325 | boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), X>, |
326 | Y> { |
327 | typedef typename boost::units::add_typeof_helper< |
328 | boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), X>, |
329 | Y>::type type; |
330 | }; |
331 | |
332 | /// Partial specialization of return type trait for action |
333 | /// X + quantity<dimensionless, Y>. |
334 | template<typename System, typename X, typename Y> |
335 | struct plain_return_type_2<arithmetic_action<plus_action>, |
336 | X, |
337 | boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> > { |
338 | typedef typename boost::units::add_typeof_helper< |
339 | X, |
340 | boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> >::type type; |
341 | }; |
342 | |
343 | /// Partial specialization of return type trait for action |
344 | /// quantity<Unit1, X> - quantity<Unit2, Y>. |
345 | template<typename Unit1, typename X, typename Unit2, typename Y> |
346 | struct plain_return_type_2<arithmetic_action<minus_action>, |
347 | boost::units::quantity<Unit1, X>, |
348 | boost::units::quantity<Unit2, Y> > { |
349 | typedef typename boost::units::subtract_typeof_helper< |
350 | boost::units::quantity<Unit1, X>, |
351 | boost::units::quantity<Unit2, Y> >::type type; |
352 | }; |
353 | |
354 | /// Partial specialization of return type trait for action |
355 | /// quantity<dimensionless, X> - Y. |
356 | template<typename System, typename X, typename Y> |
357 | struct plain_return_type_2<arithmetic_action<minus_action>, |
358 | boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), X>, |
359 | Y> { |
360 | typedef typename boost::units::subtract_typeof_helper< |
361 | boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), X>, |
362 | Y>::type type; |
363 | }; |
364 | |
365 | /// Partial specialization of return type trait for action |
366 | /// X - quantity<dimensionless, Y>. |
367 | template<typename System, typename X, typename Y> |
368 | struct plain_return_type_2<arithmetic_action<minus_action>, |
369 | X, |
370 | boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> > { |
371 | typedef typename boost::units::subtract_typeof_helper< |
372 | X, |
373 | boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> >::type type; |
374 | }; |
375 | |
376 | /// Partial specialization of return type trait for action |
377 | /// quantity<Unit1, X> * quantity<Unit2, Y>. |
378 | template<typename Unit1, typename X, typename Unit2, typename Y> |
379 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
380 | boost::units::quantity<Unit1, X>, |
381 | boost::units::quantity<Unit2, Y> > { |
382 | typedef typename boost::units::multiply_typeof_helper< |
383 | boost::units::quantity<Unit1, X>, |
384 | boost::units::quantity<Unit2, Y> >::type type; |
385 | }; |
386 | |
387 | /// Partial specialization of return type trait for action |
388 | /// quantity<Unit1, X> / quantity<Unit2, Y>. |
389 | template<typename Unit1, typename X, typename Unit2, typename Y> |
390 | struct plain_return_type_2<arithmetic_action<divide_action>, |
391 | boost::units::quantity<Unit1, X>, |
392 | boost::units::quantity<Unit2, Y> > { |
393 | typedef typename boost::units::divide_typeof_helper< |
394 | boost::units::quantity<Unit1, X>, |
395 | boost::units::quantity<Unit2, Y> >::type type; |
396 | }; |
397 | |
398 | |
399 | //////////////////////////////////////////////////////////////////////// |
400 | // Partial specialization of Boost.Lambda's trait classes for all |
401 | // operators overloaded in <boost/units/unit.hpp> |
402 | //////////////////////////////////////////////////////////////////////// |
403 | |
404 | /// Partial specialization of return type trait for action |
405 | /// +unit<Dim, System>. |
406 | template<typename Dim, typename System> |
407 | struct plain_return_type_1<unary_arithmetic_action<plus_action>, |
408 | boost::units::unit<Dim, System> > { |
409 | typedef typename boost::units::unary_plus_typeof_helper< |
410 | boost::units::unit<Dim, System> >::type type; |
411 | }; |
412 | |
413 | /// Partial specialization of return type trait for action |
414 | /// -unit<Dim, System>. |
415 | template<typename Dim, typename System> |
416 | struct plain_return_type_1<unary_arithmetic_action<minus_action>, |
417 | boost::units::unit<Dim, System> > { |
418 | typedef typename boost::units::unary_minus_typeof_helper< |
419 | boost::units::unit<Dim, System> >::type type; |
420 | }; |
421 | |
422 | /// Partial specialization of return type trait for action |
423 | /// unit<Dim1, System1> + unit<Dim2, System2>. |
424 | template<typename Dim1, typename Dim2, typename System1, typename System2> |
425 | struct plain_return_type_2<arithmetic_action<plus_action>, |
426 | boost::units::unit<Dim1, System1>, |
427 | boost::units::unit<Dim2, System2> > { |
428 | typedef typename boost::units::add_typeof_helper< |
429 | boost::units::unit<Dim1, System1>, |
430 | boost::units::unit<Dim2, System2> >::type type; |
431 | }; |
432 | |
433 | /// Partial specialization of return type trait for action |
434 | /// unit<Dim1, System1> - unit<Dim2, System2>. |
435 | template<typename Dim1, typename Dim2, typename System1, typename System2> |
436 | struct plain_return_type_2<arithmetic_action<minus_action>, |
437 | boost::units::unit<Dim1, System1>, |
438 | boost::units::unit<Dim2, System2> > { |
439 | typedef typename boost::units::subtract_typeof_helper< |
440 | boost::units::unit<Dim1, System1>, |
441 | boost::units::unit<Dim2, System2> >::type type; |
442 | }; |
443 | |
444 | /// Partial specialization of return type trait for action |
445 | /// unit<Dim1, System1> * unit<Dim2, System2>. |
446 | template<typename Dim1, typename Dim2, typename System1, typename System2> |
447 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
448 | boost::units::unit<Dim1, System1>, |
449 | boost::units::unit<Dim2, System2> > { |
450 | typedef typename boost::units::multiply_typeof_helper< |
451 | boost::units::unit<Dim1, System1>, |
452 | boost::units::unit<Dim2, System2> >::type type; |
453 | }; |
454 | |
455 | /// Partial specialization of return type trait for action |
456 | /// unit<Dim1, System1> / unit<Dim2, System2>. |
457 | template<typename Dim1, typename Dim2, typename System1, typename System2> |
458 | struct plain_return_type_2<arithmetic_action<divide_action>, |
459 | boost::units::unit<Dim1, System1>, |
460 | boost::units::unit<Dim2, System2> > { |
461 | typedef typename boost::units::divide_typeof_helper< |
462 | boost::units::unit<Dim1, System1>, |
463 | boost::units::unit<Dim2, System2> >::type type; |
464 | }; |
465 | |
466 | |
467 | //////////////////////////////////////////////////////////////////////// |
468 | // Partial specialization of Boost.Lambda's trait classes for all |
469 | // operators overloaded in <boost/units/absolute.hpp> |
470 | //////////////////////////////////////////////////////////////////////// |
471 | |
472 | |
473 | /// Partial specialization of return type trait for action |
474 | /// absolute<Y> + Y. |
475 | template<typename Y> |
476 | struct plain_return_type_2<arithmetic_action<plus_action>, |
477 | boost::units::absolute<Y>, |
478 | Y> { |
479 | typedef typename boost::units::absolute<Y> type; |
480 | }; |
481 | |
482 | /// Partial specialization of return type trait for action |
483 | /// Y + absolute<Y>. |
484 | template<typename Y> |
485 | struct plain_return_type_2<arithmetic_action<plus_action>, |
486 | Y, |
487 | boost::units::absolute<Y> > { |
488 | typedef typename boost::units::absolute<Y> type; |
489 | }; |
490 | |
491 | /// Partial specialization of return type trait for action |
492 | /// absolute<Y> - Y. |
493 | template<typename Y> |
494 | struct plain_return_type_2<arithmetic_action<minus_action>, |
495 | boost::units::absolute<Y>, |
496 | Y> { |
497 | typedef typename boost::units::absolute<Y> type; |
498 | }; |
499 | |
500 | /// Partial specialization of return type trait for action |
501 | /// absolute<Y> - absolute<Y>. |
502 | template<typename Y> |
503 | struct plain_return_type_2<arithmetic_action<minus_action>, |
504 | boost::units::absolute<Y>, |
505 | boost::units::absolute<Y> > { |
506 | typedef Y type; |
507 | }; |
508 | |
509 | /// Partial specialization of return type trait for action |
510 | /// T * absolute<unit<D, S> >. |
511 | template<typename D, typename S, typename T> |
512 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
513 | T, |
514 | boost::units::absolute<boost::units::unit<D, S> > > { |
515 | typedef typename boost::units::quantity< |
516 | boost::units::absolute<boost::units::unit<D, S> >, T> type; |
517 | }; |
518 | |
519 | } // namespace lambda |
520 | |
521 | namespace units { |
522 | |
523 | template<typename System, typename Dim, typename Arg> |
524 | struct multiply_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::absolute<boost::units::unit<Dim, System> > > { |
525 | typedef boost::lambda::lambda_functor< |
526 | boost::lambda::lambda_functor_base< |
527 | boost::lambda::arithmetic_action<boost::lambda::multiply_action>, |
528 | tuple<boost::lambda::lambda_functor<Arg>, |
529 | typename boost::lambda::const_copy_argument<const boost::units::absolute<boost::units::unit<Dim, System> > >::type> |
530 | > |
531 | > type; |
532 | }; |
533 | |
534 | /// Disambiguating overload for action |
535 | /// lambda_functor<Arg> * absolute<unit<Dim, System> > |
536 | /// based on \<boost/lambda/detail/operators.hpp\>. |
537 | template<typename System, typename Dim, typename Arg> |
538 | inline const typename multiply_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::absolute<boost::units::unit<Dim, System> > >::type |
539 | operator*(const boost::lambda::lambda_functor<Arg>& a, |
540 | const boost::units::absolute<boost::units::unit<Dim, System> >& b) { |
541 | return typename multiply_typeof_helper<boost::lambda::lambda_functor<Arg>, boost::units::absolute<boost::units::unit<Dim, System> > >::type::inherited |
542 | (tuple<boost::lambda::lambda_functor<Arg>, |
543 | typename boost::lambda::const_copy_argument<const boost::units::absolute<boost::units::unit<Dim, System> > >::type> |
544 | (a, b)); |
545 | } |
546 | |
547 | } // namespace units |
548 | |
549 | namespace lambda { |
550 | |
551 | /// Partial specialization of return type trait for action |
552 | /// absolute<unit<D, S> > * T. |
553 | template<typename D, typename S, typename T> |
554 | struct plain_return_type_2<arithmetic_action<multiply_action>, |
555 | boost::units::absolute<boost::units::unit<D, S> >, |
556 | T> { |
557 | typedef typename boost::units::quantity< |
558 | boost::units::absolute<boost::units::unit<D, S> >, T> type; |
559 | }; |
560 | |
561 | } // namespace lambda |
562 | |
563 | namespace units { |
564 | |
565 | template<typename System, typename Dim, typename Arg> |
566 | struct multiply_typeof_helper<boost::units::absolute<boost::units::unit<Dim, System> >, boost::lambda::lambda_functor<Arg> > { |
567 | typedef boost::lambda::lambda_functor< |
568 | boost::lambda::lambda_functor_base< |
569 | boost::lambda::arithmetic_action<boost::lambda::multiply_action>, |
570 | tuple<typename boost::lambda::const_copy_argument<const boost::units::absolute<boost::units::unit<Dim, System> > >::type, |
571 | boost::lambda::lambda_functor<Arg> > |
572 | > |
573 | > type; |
574 | }; |
575 | |
576 | /// Disambiguating overload for action |
577 | /// absolute<unit<Dim, System> > * lambda_functor<Arg> |
578 | /// based on \<boost/lambda/detail/operators.hpp\>. |
579 | template<typename System, typename Dim, typename Arg> |
580 | inline const typename multiply_typeof_helper<boost::units::absolute<boost::units::unit<Dim, System> >, boost::lambda::lambda_functor<Arg> >::type |
581 | operator*(const boost::units::absolute<boost::units::unit<Dim, System> >& a, |
582 | const boost::lambda::lambda_functor<Arg>& b) { |
583 | return typename multiply_typeof_helper<boost::units::absolute<boost::units::unit<Dim, System> >, boost::lambda::lambda_functor<Arg> >::type::inherited |
584 | (tuple<typename boost::lambda::const_copy_argument<const boost::units::absolute<boost::units::unit<Dim, System> > >::type, |
585 | boost::lambda::lambda_functor<Arg> > |
586 | (a, b)); |
587 | } |
588 | |
589 | } // namespace units |
590 | |
591 | } // namespace boost |
592 | |
593 | #endif // BOOST_UNITS_LAMBDA_HPP |
594 | |