Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52424 - in branches/release: boost/units/detail boost/units/systems/detail libs/units/test
From: steven_at_[hidden]
Date: 2009-04-16 14:11:24


Author: steven_watanabe
Date: 2009-04-16 14:11:23 EDT (Thu, 16 Apr 2009)
New Revision: 52424
URL: http://svn.boost.org/trac/boost/changeset/52424

Log:
Merge [51239] and [51961] from the trunk.
Added:
   branches/release/libs/units/test/test_constants.cpp
      - copied unchanged from r51961, /trunk/libs/units/test/test_constants.cpp
Text files modified:
   branches/release/boost/units/detail/conversion_impl.hpp | 105 +++------------------------------------
   branches/release/boost/units/systems/detail/constants.hpp | 2
   branches/release/libs/units/test/Jamfile.v2 | 1
   3 files changed, 10 insertions(+), 98 deletions(-)

Modified: branches/release/boost/units/detail/conversion_impl.hpp
==============================================================================
--- branches/release/boost/units/detail/conversion_impl.hpp (original)
+++ branches/release/boost/units/detail/conversion_impl.hpp 2009-04-16 14:11:23 EDT (Thu, 16 Apr 2009)
@@ -331,107 +331,18 @@
 
 } // namespace detail
 
-/// conversions between homogeneous systems are defined
+/// forward to conversion_factor (intentionally allowing ADL)
 /// INTERNAL ONLY
-template<class D, class L1, class T1, class L2, class T2>
-struct conversion_helper<quantity<unit<D, homogeneous_system<L1> >, T1>, quantity<unit<D, homogeneous_system<L2> >, T2> >
+template<class Unit1, class T1, class Unit2, class T2>
+struct conversion_helper<quantity<Unit1, T1>, quantity<Unit2, T2> >
 {
     /// INTERNAL ONLY
- typedef quantity<unit<D, homogeneous_system<L2> >, T2> destination_type;
- /// INTERNAL ONLY
- typedef typename reduce_unit<unit<D, homogeneous_system<L1> > >::type source_unit;
- /// INTERNAL ONLY
- typedef typename source_unit::system_type::type unit_list;
- static destination_type convert(const quantity<unit<D, homogeneous_system<L1> >, T1>& source)
- {
- return(destination_type::from_value(source.value() *
- detail::conversion_impl<unit_list::size::value>::template apply<
- unit_list,
- homogeneous_system<L2>
- >::value()
- ));
- }
-};
-
-/// conversions between heterogeneous systems and homogeneous systems are defined
-/// INTERNAL ONLY
-template<class D, class L1, class T1, class L2, class T2>
-struct conversion_helper<quantity<unit<D, heterogeneous_system<L1> >, T1>, quantity<unit<D, homogeneous_system<L2> >, T2> >
-{
- /// INTERNAL ONLY
- typedef quantity<unit<D, homogeneous_system<L2> >, T2> destination_type;
- static destination_type convert(const quantity<unit<D, heterogeneous_system<L1> >, T1>& source)
- {
- return(destination_type::from_value(source.value() *
- detail::conversion_impl<L1::type::size::value>::template apply<
- typename L1::type,
- homogeneous_system<L2>
- >::value() *
- eval_scale_list<typename L1::scale>::value()
- ));
- }
-};
-
-// There is no simple algorithm for doing this conversion
-// other than just defining it as the reverse of the
-// heterogeneous->homogeneous case
-/// conversions between heterogeneous systems and homogeneous systems are defined
-/// INTERNAL ONLY
-template<class D, class L1, class T1, class L2, class T2>
-struct conversion_helper<quantity<unit<D, homogeneous_system<L1> >, T1>, quantity<unit<D, heterogeneous_system<L2> >, T2> >
-{
- /// INTERNAL ONLY
- typedef quantity<unit<D, heterogeneous_system<L2> >, T2> destination_type;
- static destination_type convert(const quantity<unit<D, homogeneous_system<L1> >, T1>& source)
- {
- return(destination_type::from_value(source.value() /
- (detail::conversion_impl<L2::type::size::value>::template apply<
- typename L2::type,
- homogeneous_system<L1>
- >::value() *
- eval_scale_list<typename L2::scale>::value()
- )
- ));
- }
-};
-
-/// Requires that all possible conversions
-/// between base units are defined.
-/// INTERNAL ONLY
-template<class D, class S1, class T1, class S2, class T2>
-struct conversion_helper<quantity<unit<D, heterogeneous_system<S1> >, T1>, quantity<unit<D, heterogeneous_system<S2> >, T2> >
-{
- /// INTERNAL ONLY
- typedef quantity<unit<D, heterogeneous_system<S1> >, T1> source_type;
- /// INTERNAL ONLY
- typedef quantity<unit<D, heterogeneous_system<S2> >, T2> destination_type;
- /// INTERNAL ONLY
- typedef typename detail::extract_base_units<S1::type::size::value>::template apply<
- typename S1::type,
- dimensionless_type
- >::type from_base_units;
- /// INTERNAL ONLY
- typedef typename detail::extract_base_units<S2::type::size::value>::template apply<
- typename S2::type,
- from_base_units
- >::type all_base_units;
- /// INTERNAL ONLY
- typedef typename detail::make_homogeneous_system<all_base_units>::type system;
- /// INTERNAL ONLY
- typedef typename mpl::divides<typename S1::scale, typename S2::scale>::type result_scale;
- static destination_type convert(const source_type& source)
+ typedef quantity<Unit2, T2> destination_type;
+ static destination_type convert(const quantity<Unit1, T1>& source)
     {
- return(destination_type::from_value(source.value() *
- (detail::conversion_impl<S1::type::size::value>::template apply<
- typename S1::type,
- system
- >::value() * eval_scale_list<result_scale>::value() /
- detail::conversion_impl<S2::type::size::value>::template apply<
- typename S2::type,
- system
- >::value()
- )
- ));
+ Unit1 u1;
+ Unit2 u2;
+ return(destination_type::from_value(source.value() * conversion_factor(u1, u2)));
     }
 };
 

Modified: branches/release/boost/units/systems/detail/constants.hpp
==============================================================================
--- branches/release/boost/units/systems/detail/constants.hpp (original)
+++ branches/release/boost/units/systems/detail/constants.hpp 2009-04-16 14:11:23 EDT (Thu, 16 Apr 2009)
@@ -69,7 +69,7 @@
 } \
                                                                 \
 template<class T, class Arg1, class Arg2> \
-typename name ## _typeof_helper<typename T::value_type, template_name<Arg1, Arg2> >::type \
+typename name ## _typeof_helper<template_name<Arg1, Arg2>, typename T::value_type>::type \
 operator symbol(const template_name<Arg1, Arg2>& u, const constant<T>& t)\
 { \
     return(u symbol t.value()); \

Modified: branches/release/libs/units/test/Jamfile.v2
==============================================================================
--- branches/release/libs/units/test/Jamfile.v2 (original)
+++ branches/release/libs/units/test/Jamfile.v2 2009-04-16 14:11:23 EDT (Thu, 16 Apr 2009)
@@ -23,6 +23,7 @@
 compile test_complicated_system.cpp ;
 compile test_reduce_unit.cpp ;
 compile test_unscale.cpp ;
+compile test_constants.cpp ;
 
 run test_dimensionless_quantity.cpp ;
 run test_implicit_conversion.cpp ;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk