// -*- c++-mode -*- // // Definitions to ease the usage of Boost.Units' quantities in // functors created with the Boost.Lambda library. // // Boost.Lambda's return type deduction system is extented to make use // of Boost.Units' typeof_helper trait classes for // boost::units::quantity. // // Open issues: // // - Can some of the partial specializations be dropped? // // - Is there a need to add other specializations // (e.g, for boost::units::unit)? // // - Is there a way to work around boost::lambda:bind's limitation // concerning the binding of overloaded functions? The required // static_cast to the function pointer (referring, e.g., a function // from boost/units/cmath.hpp) is tedious. // // Copyright (C) 2008 Torsten Maehne // // Boost.Units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2008 Matthias Christian Schabel // Copyright (C) 2008 Steven Watanabe // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_UNITS_LAMBDA_HPP #define BOOST_UNITS_LAMBDA_HPP #include #include #include namespace boost { namespace lambda { // partial specialisation of return type trait for action // +quantity template struct plain_return_type_1, boost::units::quantity > { typedef typename boost::units::unary_plus_typeof_helper >::type type; }; // partial specialisation of return type trait for action // -quantity template struct plain_return_type_1, boost::units::quantity > { typedef typename boost::units::unary_minus_typeof_helper >::type type; }; // partial specialisation 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, Y>::type type; }; // partial specialisation 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 >::type type; }; // partial specialisation of return type trait for action // quantity + quantity template struct plain_return_type_2, boost::units::quantity, boost::units::quantity > { typedef typename boost::units::add_typeof_helper, boost::units::quantity >::type type; }; // partial specialisation 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, Y>::type type; }; // partial specialisation 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 >::type type; }; // partial specialisation of return type trait for action // quantity - quantity template struct plain_return_type_2, boost::units::quantity, boost::units::quantity > { typedef typename boost::units::subtract_typeof_helper, boost::units::quantity >::type type; }; // partial specialisation of return type trait for action // quantity * Y template struct plain_return_type_2, boost::units::quantity, Y> { typedef typename boost::units::multiply_typeof_helper, Y>::type type; }; // partial specialisation of return type trait for action // X * quantity template struct plain_return_type_2, X, boost::units::quantity > { typedef typename boost::units::multiply_typeof_helper >::type type; }; // partial specialisation of return type trait for action // quantity * quantity template struct plain_return_type_2, boost::units::quantity, boost::units::quantity > { typedef typename boost::units::multiply_typeof_helper, boost::units::quantity >::type type; }; // partial specialisation of return type trait for action // quantity / Y template struct plain_return_type_2, boost::units::quantity, Y> { typedef typename boost::units::divide_typeof_helper, Y>::type type; }; // partial specialisation of return type trait for action // X / quantity template struct plain_return_type_2, X, boost::units::quantity > { typedef typename boost::units::divide_typeof_helper >::type type; }; // partial specialisation of return type trait for action // quantity / quantity template struct plain_return_type_2, boost::units::quantity, boost::units::quantity > { typedef typename boost::units::divide_typeof_helper, boost::units::quantity >::type type; }; } } #endif // BOOST_UNITS_LAMBDA_HPP