Index: boost/units/lambda.hpp =================================================================== --- boost/units/lambda.hpp (Revision 48214) +++ boost/units/lambda.hpp (Arbeitskopie) @@ -34,6 +34,7 @@ #include #include +#include #include namespace boost { @@ -318,6 +319,28 @@ }; /// Partial specialization of return type trait for action + /// quantity + Y. + template + struct plain_return_type_2, + boost::units::quantity, + Y> { + typedef typename boost::units::add_typeof_helper< + boost::units::quantity, + Y>::type type; + }; + + /// Partial specialization of return type trait for action + /// X + quantity. + template + struct plain_return_type_2, + X, + boost::units::quantity > { + typedef typename boost::units::add_typeof_helper< + X, + boost::units::quantity >::type type; + }; + + /// Partial specialization of return type trait for action /// quantity - quantity. template struct plain_return_type_2, @@ -329,6 +352,28 @@ }; /// Partial specialization of return type trait for action + /// quantity - Y. + template + struct plain_return_type_2, + boost::units::quantity, + Y> { + typedef typename boost::units::subtract_typeof_helper< + boost::units::quantity, + Y>::type type; + }; + + /// Partial specialization of return type trait for action + /// X - quantity. + template + struct plain_return_type_2, + X, + boost::units::quantity > { + typedef typename boost::units::subtract_typeof_helper< + X, + boost::units::quantity >::type type; + }; + + /// Partial specialization of return type trait for action /// quantity * quantity. template struct plain_return_type_2, Index: libs/units/test/test_lambda.cpp =================================================================== --- libs/units/test/test_lambda.cpp (Revision 48214) +++ libs/units/test/test_lambda.cpp (Arbeitskopie) @@ -142,9 +142,21 @@ // quantity + quantity BOOST_CHECK(((bl::_1 + bl::_2)(2.0 * bu::meter, 4.0 * bu::meter) == 6.0 * bu::meter)); + // quantity + Y + BOOST_CHECK(((bl::_1 + 1.0f)(bu::quantity(2.0)) == 3.0)); + + // X + quantity + BOOST_CHECK(((1.0f + bl::_1)(bu::quantity(1.0)) == 2.0)); + // quantity - quantity BOOST_CHECK(((bl::_1 - bl::_2)(2.0 * bu::meter, 4.0 * bu::meter) == -2.0 * bu::meter)); + // quantity - Y + BOOST_CHECK(((bl::_1 - 2.0f)(bu::quantity(1.0)) == -1.0)); + + // X - quantity + BOOST_CHECK(((2.0f - bl::_1)(bu::quantity(1.0)) == 1.0)); + // quantity * quantity BOOST_CHECK(((bl::_1 * bl::_2)(2.0 * bu::kilogram, 4.0 * bu::meter_per_second) == 8.0 * bu::kilogram * bu::meter_per_second));