annotate DEPENDENCIES/generic/include/boost/units/lambda.hpp @ 133:4acb5d8d80b6 tip

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