|
From: Steven W. <ste...@us...> - 2007-04-04 19:14:45
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15003/boost-sandbox/boost/units Modified Files: static_rational.hpp Log Message: Added mpl arithmetic Index: static_rational.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/static_rational.hpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- static_rational.hpp 16 Mar 2007 18:12:42 -0000 1.1.1.1 +++ static_rational.hpp 4 Apr 2007 19:14:27 -0000 1.2 @@ -16,6 +16,8 @@ #include <boost/math/common_factor.hpp> +#include <boost/mpl/arithmetic.hpp> + #include <boost/units/operators.hpp> /// \file @@ -25,6 +27,12 @@ namespace units { +namespace detail { + +struct static_rational_tag {}; + +} + typedef long integer_type; /// Compile time absolute value. @@ -66,6 +74,7 @@ static_cast<integer_type>(boost::math::static_gcd<nabs,dabs>::value); public: + typedef detail::static_rational_tag tag; static const integer_type Numerator = N/den, Denominator = D/den; @@ -323,6 +332,57 @@ } // namespace units +namespace mpl { + +template<> +struct plus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag> +{ + template<class T0, class T1> + struct apply { + typedef typename boost::units::static_add<T0, T1>::type type; + }; +}; + +template<> +struct minus_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag> +{ + template<class T0, class T1> + struct apply { + typedef typename boost::units::static_subtract<T0, T1>::type type; + }; +}; + +template<> +struct times_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag> +{ + template<class T0, class T1> + struct apply { + typedef typename boost::units::static_multiply<T0, T1>::type type; + }; +}; + +template<> +struct divides_impl<boost::units::detail::static_rational_tag, boost::units::detail::static_rational_tag> +{ + template<class T0, class T1> + struct apply { + typedef typename boost::units::static_divide<T0, T1>::type type; + }; +}; + +template<> +struct negate_impl<boost::units::detail::static_rational_tag> +{ + template<class T0> + struct apply { + typedef typename boost::units::static_negate<T0>::type type; + }; +}; + + + +} + } // namespace boost #endif // BOOST_UNITS_STATIC_RATIONAL_HPP |