Boost logo

Boost-Commit :

From: boost_at_[hidden]
Date: 2007-10-18 20:25:45


Author: matthiasschabel
Date: 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
New Revision: 40169
URL: http://svn.boost.org/trac/boost/changeset/40169

Log:
cleanup
Text files modified:
   sandbox/units/boost/units/absolute.hpp | 172 +++--------
   sandbox/units/boost/units/conversion.hpp | 574 +--------------------------------------
   sandbox/units/boost/units/detail/linear_algebra.hpp | 24
   sandbox/units/boost/units/dim.hpp | 13
   sandbox/units/boost/units/homogeneous_system.hpp | 2
   sandbox/units/boost/units/systems/base_units.hpp | 63 ++--
   sandbox/units/boost/units/systems/other/non_si_units.hpp | 6
   sandbox/units/boost/units/units_fwd.hpp | 5
   sandbox/units/libs/units/doc/units.qbk | 4
   sandbox/units/libs/units/example/complex.cpp | 36 ++
   sandbox/units/libs/units/example/non_base_dimension.cpp | 2
   sandbox/units/libs/units/example/radar_beam_height.cpp | 4
   sandbox/units/libs/units/example/temperature.cpp | 14
   sandbox/units/libs/units/test/test_conversion.cpp | 19 -
   sandbox/units/libs/units/test/test_default_conversion.cpp | 2
   sandbox/units/libs/units/tutorial/tutorial_1.cpp | 196 +++++++++++--
   16 files changed, 333 insertions(+), 803 deletions(-)

Modified: sandbox/units/boost/units/absolute.hpp
==============================================================================
--- sandbox/units/boost/units/absolute.hpp (original)
+++ sandbox/units/boost/units/absolute.hpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -13,21 +13,17 @@
 
 #include <iosfwd>
 
-#include <boost/type_traits/is_base_and_derived.hpp>
-
-#include <boost/units/config.hpp>
-#include <boost/units/conversion.hpp>
-#include <boost/units/heterogeneous_system.hpp>
-#include <boost/units/units_fwd.hpp>
+#include <boost/units/detail/absolute_impl.hpp>
 
 namespace boost {
 
 namespace units {
 
-/// A wrapper to represent absolute units. Intended
-/// originally for temperatures, this template causes
-/// absolute<T> +/- T -> absolute<T>
-/// absolute<T> - absolute<T> -> T
+/// A wrapper to represent absolute units (points rather than vectors). Intended
+/// originally for temperatures, this class implements operators for absolute units
+/// so that addition of a relative unit to an absolute unit results in another
+/// absolute unit : absolute<T> +/- T -> absolute<T> and subtraction of one absolute
+/// unit from another results in a relative unit : absolute<T> - absolute<T> -> T
 template<class Y>
 class absolute
 {
@@ -50,116 +46,6 @@
         value_type val_;
 };
 
-} // namespace units
-
-} // namespace boost
-
-#if BOOST_UNITS_HAS_BOOST_TYPEOF
-
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::absolute, (class))
-
-#endif
-
-namespace boost {
-
-namespace units {
-
-namespace detail {
-
-struct undefined_affine_conversion_base {};
-
-}
-
-/// INTERNAL ONLY
-template<class From, class To>
-struct affine_conversion_helper : detail::undefined_affine_conversion_base {};
-
-namespace detail {
-
-template<bool IsDefined, bool ReverseIsDefined>
-struct affine_conversion_impl;
-
-template<bool ReverseIsDefined>
-struct affine_conversion_impl<true, ReverseIsDefined>
-{
- template<class Unit1, class Unit2, class T0, class T1>
- struct apply {
- static T1 value(const T0& t0)
- {
- return(
- t0 *
- conversion_factor(Unit1(), Unit2()) +
- affine_conversion_helper<typename reduce_unit<Unit1>::type, typename reduce_unit<Unit2>::type>::value());
- }
- };
-};
-
-template<>
-struct affine_conversion_impl<false, true>
-{
- template<class Unit1, class Unit2, class T0, class T1>
- struct apply
- {
- static T1 value(const T0& t0)
- {
- return(
- (t0 - affine_conversion_helper<typename reduce_unit<Unit2>::type, typename reduce_unit<Unit1>::type>::value()) *
- conversion_factor(Unit1(), Unit2()));
- }
- };
-};
-
-}
-
-/// INTERNAL ONLY
-template<class Unit1, class T1, class Unit2, class T2>
-struct conversion_helper<quantity<absolute<Unit1>, T1>, quantity<absolute<Unit2>, T2> >
-{
- typedef quantity<absolute<Unit1>, T1> from_quantity_type;
- typedef quantity<absolute<Unit2>, T2> to_quantity_type;
- static to_quantity_type convert(const from_quantity_type& source)
- {
- return(
- to_quantity_type::from_value(
- detail::affine_conversion_impl<
- !boost::is_base_and_derived<
- detail::undefined_affine_conversion_base,
- affine_conversion_helper<typename reduce_unit<Unit1>::type, typename reduce_unit<Unit2>::type>
- >::value,
- !boost::is_base_and_derived<
- detail::undefined_affine_conversion_base,
- affine_conversion_helper<typename reduce_unit<Unit2>::type, typename reduce_unit<Unit1>::type>
- >::value
- >::template apply<Unit1, Unit2, T1, T2>::value(source.value())
- )
- );
- }
-};
-
-/// Defines the offset between two absolute units.
-/// Requires the value to be in the destination units e.g
-/// @code
-/// BOOST_UNITS_DEFINE_AFFINE_CONVERSION(celsius_base_unit, fahrenheit_base_unit::unit_type, double, 32.0);
-/// @endcode
-/// @c BOOST_UNITS_DEFINE_CONVERSION is also necessary to
-/// specify the conversion factor. Like @c BOOST_UNITS_DEFINE_CONVERSION
-/// defining celsius->fahrenheit as above will be sufficient
-/// to get fahrenheit->celsius also.
-#define BOOST_UNITS_DEFINE_AFFINE_CONVERSION(From, To, type_, value_) \
- namespace boost { \
- namespace units { \
- template<> \
- struct affine_conversion_helper<From, To> \
- { \
- typedef type_ type; \
- static type value() { return(value_); } \
- }; \
- } \
- } \
- void boost_units_require_semicolon()
-
 /// add a relative value to an absolute one
 template<class Y>
 absolute<Y> operator+(const absolute<Y>& aval,const Y& rval)
@@ -188,13 +74,6 @@
     return Y(aval1.value()-aval2.value());
 }
 
-/// INTERNAL ONLY
-template<class D, class S>
-struct reduce_unit<absolute<unit<D, S> > >
-{
- typedef absolute<typename reduce_unit<unit<D, S> >::type> type;
-};
-
 /// multiplying an absolute unit by a scalar gives a quantity
 /// just like an ordinary unit
 template<class D, class S, class T>
@@ -224,4 +103,43 @@
 
 } // namespace boost
 
+#if BOOST_UNITS_HAS_BOOST_TYPEOF
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::absolute, (class))
+
+#endif
+
+namespace boost {
+
+namespace units {
+
+/// Macro to define the offset between two absolute units.
+/// Requires the value to be in the destination units e.g
+/// @code
+/// BOOST_UNITS_DEFINE_CONVERSION_OFFSET(celsius_base_unit, fahrenheit_base_unit::unit_type, double, 32.0);
+/// @endcode
+/// @c BOOST_UNITS_DEFINE_CONVERSION_FACTOR is also necessary to
+/// specify the conversion factor. Like @c BOOST_UNITS_DEFINE_CONVERSION_FACTOR
+/// this macro defines both forward and reverse conversions so
+/// defining, e.g., the conversion from celsius to fahrenheit as above will also
+/// define the inverse conversion from fahrenheit to celsius.
+#define BOOST_UNITS_DEFINE_CONVERSION_OFFSET(From, To, type_, value_) \
+ namespace boost { \
+ namespace units { \
+ template<> \
+ struct affine_conversion_helper<From, To> \
+ { \
+ typedef type_ type; \
+ static type value() { return(value_); } \
+ }; \
+ } \
+ } \
+ void boost_units_require_semicolon()
+
+} // namespace units
+
+} // namespace boost
+
 #endif // BOOST_UNITS_ABSOLUTE_HPP

Modified: sandbox/units/boost/units/conversion.hpp
==============================================================================
--- sandbox/units/boost/units/conversion.hpp (original)
+++ sandbox/units/boost/units/conversion.hpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -11,25 +11,7 @@
 #ifndef BOOST_UNITS_CONVERSION_HPP
 #define BOOST_UNITS_CONVERSION_HPP
 
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/begin.hpp>
-#include <boost/mpl/next.hpp>
-#include <boost/mpl/deref.hpp>
-#include <boost/mpl/divides.hpp>
-#include <boost/preprocessor/seq/enum.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/is_base_and_derived.hpp>
-
-#include <boost/units/dimension_list.hpp>
-#include <boost/units/heterogeneous_system.hpp>
-#include <boost/units/homogeneous_system.hpp>
-#include <boost/units/scaled_base_unit.hpp>
-#include <boost/units/static_rational.hpp>
-#include <boost/units/units_fwd.hpp>
-#include <boost/units/detail/heterogeneous_conversion.hpp>
-#include <boost/units/detail/one.hpp>
-#include <boost/units/detail/static_rational_power.hpp>
+#include <boost/units/detail/conversion_impl.hpp>
 
 namespace boost {
 
@@ -67,300 +49,12 @@
 
 #endif
 
-namespace detail {
-
-template<class Source, class Dest>
-struct conversion_factor_helper;
-
-template<class Source, class Dest>
-struct call_base_unit_converter;
-
-}
-
-/// INTERNAL ONLY
-struct undefined_base_unit_converter_base {};
-
-/// INTERNAL ONLY
-struct no_default_conversion {};
-
-/// INTERNAL ONLY
-template<class BaseUnit>
-struct unscaled_get_default_conversion : no_default_conversion {};
-
-/// INTERNAL ONLY
-template<bool is_defined>
-struct unscaled_get_default_conversion_impl;
-
-/// INTERNAL ONLY
-template<>
-struct unscaled_get_default_conversion_impl<true>
-{
- template<class T>
- struct apply
- {
- typedef typename unscaled_get_default_conversion<typename unscale<T>::type>::type type;
- };
-};
-
-/// INTERNAL ONLY
-template<>
-struct unscaled_get_default_conversion_impl<false>
-{
- template<class T>
- struct apply
- {
- typedef typename T::unit_type type;
- };
-};
-
-/// INTERNAL ONLY
-template<class BaseUnit>
-struct get_default_conversion
-{
- typedef typename unscaled_get_default_conversion_impl<
- !boost::is_base_and_derived<no_default_conversion, unscaled_get_default_conversion<typename unscale<BaseUnit>::type> >::value
- >::template apply<BaseUnit>::type type;
-};
-
-/// INTERNAL ONLY
-template<class Source, class Destination>
-struct select_base_unit_converter
-{
- typedef Source source_type;
- typedef Destination destination_type;
-};
-
-/// INTERNAL ONLY
-template<class Source, class Dest>
-struct base_unit_converter_base : undefined_base_unit_converter_base {};
-
-/// INTERNAL ONLY
-template<class Source>
-struct base_unit_converter_base<Source, BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Source, typename Source::dimension_type)>
-{
- typedef one type;
- static type value() {
- return(one());
- }
-};
-
-/// INTERNAL ONLY
-template<class Source, class Dest>
-struct base_unit_converter : base_unit_converter_base<Source, Dest> {};
-
-namespace detail {
-
-template<bool is_defined>
-struct do_call_base_unit_converter_impl;
-
-template<>
-struct do_call_base_unit_converter_impl<true>
-{
- template<class Source, class Dest>
- struct apply : base_unit_converter<Source, Dest> {};
-};
-
-template<>
-struct do_call_base_unit_converter_impl<false>
-{
- template<class Source, class Dest>
- struct apply {
- typedef select_base_unit_converter<typename unscale<Source>::type, typename unscale<Dest>::type> selector;
- typedef typename selector::source_type source_type;
- typedef typename selector::destination_type destination_type;
- typedef base_unit_converter<source_type, destination_type> converter;
- typedef typename mpl::divides<typename get_scale_list<Source>::type, typename get_scale_list<source_type>::type>::type source_factor;
- typedef typename mpl::divides<typename get_scale_list<Dest>::type, typename get_scale_list<destination_type>::type>::type destination_factor;
- typedef typename mpl::divides<source_factor, destination_factor>::type factor;
- typedef eval_scale_list<factor> eval_factor;
- typedef typename multiply_typeof_helper<typename converter::type, typename eval_factor::type>::type type;
- static type value()
- {
- return(converter::value() * eval_factor::value());
- }
- };
-};
-
-template<class Source, class Dest>
-struct do_call_base_unit_converter :
- do_call_base_unit_converter_impl<
- !boost::is_base_and_derived<
- undefined_base_unit_converter_base,
- base_unit_converter<Source, Dest>
- >::value
- >::template apply<Source, Dest> {};
-
-template<bool forward_is_defined, bool reverse_is_defined>
-struct call_base_unit_converter_base_unit_impl;
-
-template<>
-struct call_base_unit_converter_base_unit_impl<true, true>
-{
- template<class Source, class Dest>
- struct apply : do_call_base_unit_converter<Source, typename Dest::unit_type>
- {
- };
-};
-
-template<>
-struct call_base_unit_converter_base_unit_impl<true, false>
-{
- template<class Source, class Dest>
- struct apply : do_call_base_unit_converter<Source, typename Dest::unit_type>
- {
- };
-};
-
-template<>
-struct call_base_unit_converter_base_unit_impl<false, true>
-{
- template<class Source, class Dest>
- struct apply
- {
- typedef do_call_base_unit_converter<Dest, typename Source::unit_type> converter;
- typedef typename divide_typeof_helper<one, typename converter::type>::type type;
- static type value() {
- return(one() / converter::value());
- }
- };
-};
-
-template<>
-struct call_base_unit_converter_base_unit_impl<false, false>
-{
- template<class Source, class Dest>
- struct apply
- {
- typedef typename get_default_conversion<Source>::type new_source;
- typedef typename get_default_conversion<Dest>::type new_dest;
- typedef call_base_unit_converter<Source, new_source> start;
- typedef detail::conversion_factor_helper<
- new_source,
- new_dest
- > conversion;
- typedef call_base_unit_converter<Dest, new_dest> end;
- typedef typename divide_typeof_helper<
- typename multiply_typeof_helper<
- typename start::type,
- typename conversion::type
- >::type,
- typename end::type
- >::type type;
- static type value() {
- return(start::value() * conversion::value() / end::value());
- }
- };
-};
-
-template<int N>
-struct get_default_conversion_impl
-{
- template<class Begin>
- struct apply
- {
- typedef typename mpl::deref<Begin>::type source_pair;
- typedef typename source_pair::value_type exponent;
- typedef typename source_pair::tag_type source;
- typedef typename get_default_conversion<source>::type new_source;
- typedef typename get_default_conversion_impl<N-1>::template apply<typename mpl::next<Begin>::type> next_iteration;
- typedef typename multiply_typeof_helper<typename power_dimof_helper<new_source, exponent>::type, typename next_iteration::unit_type>::type unit_type;
- typedef call_base_unit_converter<source, new_source> conversion;
- typedef typename multiply_typeof_helper<typename conversion::type, typename next_iteration::type>::type type;
- static type value() {
- return(static_rational_power<exponent>(conversion::value()) * next_iteration::value());
- }
- };
-};
-
-template<>
-struct get_default_conversion_impl<0>
-{
- template<class Begin>
- struct apply
- {
- typedef unit<dimensionless_type, heterogeneous_system<heterogeneous_system_pair<dimensionless_type, dimensionless_type> > > unit_type;
- typedef one type;
- static type value() {
- return(type());
- }
- };
-};
-
-template<bool is_defined>
-struct call_base_unit_converter_impl;
-
-template<>
-struct call_base_unit_converter_impl<true>
-{
- template<class Source, class Dest>
- struct apply : do_call_base_unit_converter<Source, Dest>
- {
- };
-};
-
-template<>
-struct call_base_unit_converter_impl<false>
-{
- template<class Source, class Dest>
- struct apply {
- typedef typename get_default_conversion<Source>::type new_source;
- typedef typename Dest::system_type::type system_list;
- typedef typename get_default_conversion_impl<mpl::size<system_list>::value>::template apply<typename mpl::begin<system_list>::type> impl;
- typedef typename impl::unit_type new_dest;
- typedef call_base_unit_converter<Source, new_source> start;
- typedef conversion_factor_helper<new_source, new_dest> conversion;
- typedef typename divide_typeof_helper<
- typename multiply_typeof_helper<
- typename start::type,
- typename conversion::type
- >::type,
- typename impl::type
- >::type type;
- static type value() {
- return(start::value() * conversion::value() / impl::value());
- }
- };
-};
-
-template<class Source, class Dest>
-struct base_unit_converter_scaled_is_undefined :
- boost::is_base_and_derived<
- undefined_base_unit_converter_base,
- base_unit_converter<typename unscale<Source>::type, typename unscale<Dest>::type>
- > {};
-
-template<class Source, class Dest>
-struct base_unit_converter_is_undefined :
- mpl::and_<
- boost::is_base_and_derived<
- undefined_base_unit_converter_base,
- base_unit_converter<Source, Dest>
- >,
- base_unit_converter_scaled_is_undefined<Source, Dest>
- > {};
-
-template<class Source, class Dest>
-struct call_base_unit_converter : call_base_unit_converter_impl<!base_unit_converter_is_undefined<Source, Dest>::value>::template apply<Source, Dest>
-{
-};
-
-template<class Source, class Dest>
-struct call_base_unit_converter<Source, BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Dest, typename Source::dimension_type)> :
- call_base_unit_converter_base_unit_impl<
- !base_unit_converter_is_undefined<Source, typename Dest::unit_type>::value,
- !base_unit_converter_is_undefined<Dest, typename Source::unit_type>::value
- >::template apply<Source, Dest>
-{
-};
-
-} // namespace detail
-
 /// Defines the conversion factor from a base unit to any other base
 /// unit with the same dimensions. Must appear at global scope.
 /// The reverse need not be defined.
 #define BOOST_UNITS_DEFINE_BASE_CONVERSION(Source, Destination, type_, value_) \
-namespace boost { \
-namespace units { \
+ namespace boost { \
+ namespace units { \
     template<> \
     struct select_base_unit_converter< \
         unscale<Source>::type, \
@@ -379,16 +73,16 @@
         typedef type_ type; \
         static type value() { return(value_); } \
     }; \
-} \
-} \
-void boost_units_require_semicolon()
+ } \
+ } \
+ void boost_units_require_semicolon()
 
 /// Defines the conversion factor from a base unit to any other base
 /// unit with the same dimensions. Must appear at global scope.
 /// The reverse need not be defined. Neither base unit may be scaled.
 #define BOOST_UNITS_DEFINE_BASE_CONVERSION_TEMPLATE(Params, Source, Destination, type_, value_) \
-namespace boost { \
-namespace units { \
+ namespace boost { \
+ namespace units { \
     template<BOOST_PP_SEQ_ENUM(Params)> \
     struct base_unit_converter< \
         Source, \
@@ -398,18 +92,18 @@
         typedef type_ type; \
         static type value() { return(value_); } \
     }; \
-} \
-} \
-void boost_units_require_semicolon()
+ } \
+ } \
+ void boost_units_require_semicolon()
 
 /// Defines the conversion factor from a base unit to any unit
 /// with the correct dimensions. Must appear at global scope.
 /// If the destination unit is a unit that contains only one
 /// base unit which is raised to the first power (e.g. feet->meters)
 /// the reverse need not be defined.
-#define BOOST_UNITS_DEFINE_CONVERSION(Source, Destination, type_, value_) \
-namespace boost { \
-namespace units { \
+#define BOOST_UNITS_DEFINE_CONVERSION_FACTOR(Source, Destination, type_, value_) \
+ namespace boost { \
+ namespace units { \
     template<> \
     struct select_base_unit_converter< \
         unscale<Source>::type, \
@@ -425,9 +119,9 @@
         typedef type_ type; \
         static type value() { return(value_); } \
     }; \
-} \
-} \
-void boost_units_require_semicolon()
+ } \
+ } \
+ void boost_units_require_semicolon()
 
 /// Defines the conversion factor from a base unit to any unit
 /// with the correct dimensions. Must appear at global scope.
@@ -437,18 +131,18 @@
 /// The destination must be a heterogeneous unit. These requirements
 /// are rather difficult to check. If they are not met the specialization
 /// will probably vanish silently.
-#define BOOST_UNITS_DEFINE_CONVERSION_TEMPLATE(Params, Source, Destination, type_, value_) \
-namespace boost { \
-namespace units { \
+#define BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE(Params, Source, Destination, type_, value_) \
+ namespace boost { \
+ namespace units { \
     template<BOOST_PP_SEQ_ENUM(Params)> \
     struct base_unit_converter<Source, Destination> \
     { \
         typedef type_ type; \
         static type value() { return(value_); } \
     }; \
-} \
-} \
-void boost_units_require_semicolon()
+ } \
+ } \
+ void boost_units_require_semicolon()
 
 /// Specifies the default conversion to be applied when
 /// no direct conversion is available.
@@ -484,226 +178,6 @@
     } \
     void boost_units_require_semicolon()
 
-namespace detail {
-
-template<int N>
-struct conversion_impl
-{
- template<class Begin, class DestinationSystem>
- struct apply
- {
- typedef typename conversion_impl<N-1>::template apply<
- typename mpl::next<Begin>::type,
- DestinationSystem
- > next_iteration;
- typedef typename mpl::deref<Begin>::type unit_pair;
- typedef typename unit_pair::tag_type unit;
- typedef typename unit::dimension_type dimensions;
- typedef typename reduce_unit<units::unit<dimensions, DestinationSystem> >::type reduced_unit;
- typedef detail::call_base_unit_converter<unit, reduced_unit> converter;
- typedef typename multiply_typeof_helper<typename converter::type, typename next_iteration::type>::type type;
- static type value() { return(static_rational_power<typename unit_pair::value_type>(converter::value()) * next_iteration::value()); }
- };
-};
-
-template<>
-struct conversion_impl<0>
-{
- template<class Begin, class DestinationSystem>
- struct apply
- {
- typedef one type;
- static type value() { return(one()); }
- };
-};
-
-} // namespace detail
-
-/// conversions between 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, homogeneous_system<L2> >, 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<mpl::size<unit_list>::value>::template apply<
- typename mpl::begin<unit_list>::type,
- 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<mpl::size<typename L1::type>::value>::template apply<
- typename mpl::begin<typename L1::type>::type,
- homogeneous_system<L2>
- >::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<mpl::size<typename L2::type>::value>::template apply<
- typename mpl::begin<typename L2::type>::type,
- homogeneous_system<L1>
- >::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<mpl::size<typename S1::type>::value>::template apply<
- typename mpl::begin<typename S1::type>::type,
- mpl::list0<>
- >::type from_base_units;
- /// INTERNAL ONLY
- typedef typename detail::extract_base_units<mpl::size<typename S2::type>::value>::template apply<
- typename mpl::begin<typename S2::type>::type,
- from_base_units
- >::type all_base_units;
- /// INTERNAL ONLY
- typedef typename detail::make_homogeneous_system<all_base_units>::type system;
- static destination_type convert(const source_type& source)
- {
- return(destination_type::from_value(source.value() *
- (detail::conversion_impl<mpl::size<typename S1::type>::value>::template apply<
- typename mpl::begin<typename S1::type>::type,
- system
- >::value() /
- detail::conversion_impl<mpl::size<typename S2::type>::value>::template apply<
- typename mpl::begin<typename S2::type>::type,
- system
- >::value()
- )
- ));
- }
-};
-
-namespace detail {
-
-template<class Source, class Dest>
-struct conversion_factor_helper;
-
-template<class D, class L1, class L2>
-struct conversion_factor_helper<unit<D, homogeneous_system<L1> >, unit<D, homogeneous_system<L2> > >
-{
- typedef typename reduce_unit<unit<D, homogeneous_system<L1> > >::type source_unit;
- typedef typename source_unit::system_type::type unit_list;
- typedef typename detail::conversion_impl<mpl::size<unit_list>::value>::template apply<
- typename mpl::begin<unit_list>::type,
- homogeneous_system<L2>
- > impl;
- typedef typename impl::type type;
- static type value()
- {
- return(impl::value());
- }
-};
-
-template<class D, class L1, class L2>
-struct conversion_factor_helper<unit<D, heterogeneous_system<L1> >, unit<D, homogeneous_system<L2> > >
-{
- typedef typename detail::conversion_impl<mpl::size<typename L1::type>::value>::template apply<
- typename mpl::begin<typename L1::type>::type,
- homogeneous_system<L2>
- > impl;
- typedef typename impl::type type;
- static type value()
- {
- return(impl::value());
- }
-};
-
-// There is no simple algorithm for doing this conversion
-// other than just defining it as the reverse of the
-// heterogeneous->homogeneous case
-template<class D, class L1, class L2>
-struct conversion_factor_helper<unit<D, homogeneous_system<L1> >, unit<D, heterogeneous_system<L2> > >
-{
- typedef typename detail::conversion_impl<mpl::size<typename L2::type>::value>::template apply<
- typename mpl::begin<typename L2::type>::type,
- homogeneous_system<L1>
- > impl;
- typedef typename impl::type type;
- static type value()
- {
- return(one() / impl::value());
- }
-};
-
-/// Requires that all possible conversions
-/// between base units are defined.
-template<class D, class S1, class S2>
-struct conversion_factor_helper<unit<D, heterogeneous_system<S1> >, unit<D, heterogeneous_system<S2> > >
-{
- /// INTERNAL ONLY
- typedef typename detail::extract_base_units<mpl::size<typename S1::type>::value>::template apply<
- typename mpl::begin<typename S1::type>::type,
- mpl::list0<>
- >::type from_base_units;
- /// INTERNAL ONLY
- typedef typename detail::extract_base_units<mpl::size<typename S2::type>::value>::template apply<
- typename mpl::begin<typename S2::type>::type,
- from_base_units
- >::type all_base_units;
- /// INTERNAL ONLY
- typedef typename detail::make_homogeneous_system<all_base_units>::type system;
- typedef typename detail::conversion_impl<mpl::size<typename S1::type>::value>::template apply<
- typename mpl::begin<typename S1::type>::type,
- system
- > conversion1;
- typedef typename detail::conversion_impl<mpl::size<typename S2::type>::value>::template apply<
- typename mpl::begin<typename S2::type>::type,
- system
- > conversion2;
- typedef typename divide_typeof_helper<typename conversion1::type, typename conversion2::type>::type type;
- static type value()
- {
- return(conversion1::value() / conversion2::value());
- }
-};
-
-} // namespace detail
-
 /// Find the conversion factor between two units.
 template<class FromUnit,class ToUnit>
 inline
@@ -743,4 +217,4 @@
 
 } // namespace boost
 
-#endif
+#endif // BOOST_UNITS_CONVERSION_HPP

Modified: sandbox/units/boost/units/detail/linear_algebra.hpp
==============================================================================
--- sandbox/units/boost/units/detail/linear_algebra.hpp (original)
+++ sandbox/units/boost/units/detail/linear_algebra.hpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -74,7 +74,7 @@
 template<int N>
 struct normalize_units_impl;
 
-struct inconsistant {};
+struct inconsistent {};
 
 // eliminate_from_pair_of_equations takes a pair of
 // equations and eliminates the first variable.
@@ -125,7 +125,7 @@
 };
 
 // Eliminates the first variable from a list of equations
-// returns inconsistant if all its coefficients are 0. Otherwise
+// returns inconsistent if all its coefficients are 0. Otherwise
 // recursively calls solve to find the remaining variables
 //
 // list<rational> eliminate(list<equation> system) {
@@ -143,7 +143,7 @@
 // }
 // }
 // if(eliminate_against == null) {
-// return(inconsistant);
+// return(inconsistent);
 // } else {
 // list<rational> solution = solve(result);
 // return(push_front(solution, substitute(eliminate_against,solution)));
@@ -173,7 +173,7 @@
 struct elimination_skip_leading_zeros_impl<true, true> {
     template<class Begin, int N, class L>
     struct apply {
- typedef inconsistant type;
+ typedef inconsistent type;
     };
 };
 
@@ -211,10 +211,10 @@
 };
 
 template<>
-struct combine_solutions<inconsistant> {
+struct combine_solutions<inconsistent> {
     template<class Iterator>
     struct apply {
- typedef inconsistant type;
+ typedef inconsistent type;
     };
 };
 
@@ -310,7 +310,7 @@
 struct check_extra_equations_func {
     template<class Begin, int N>
     struct apply {
- typedef inconsistant type;
+ typedef inconsistent type;
     };
 };
 
@@ -712,7 +712,7 @@
 
 // S is the solution for this particular base dimension.
 // if the base dimension cannot be represented then
-// solve will return inconsistant hence the two specializations.
+// solve will return inconsistent hence the two specializations.
 
 template<class S>
 struct normalize_units_func {
@@ -756,7 +756,7 @@
 // cannot be represented with the base units
 // and the dummies allready added.
 template<>
-struct normalize_units_func<inconsistant> {
+struct normalize_units_func<inconsistent> {
     template<class ReverseEquations, int M, class DimensionIterator, int N, int Extra, int I, class ExtraEquations>
     struct apply {
         // Find the position that needs to be erased. (Since this
@@ -957,7 +957,7 @@
 
 
 // strip_zeroes erases the first N elements of a list if
-// they are all zero, otherwise returns inconsistant
+// they are all zero, otherwise returns inconsistent
 //
 // list strip_zeroes(list l, int N) {
 // if(N == 0) {
@@ -965,7 +965,7 @@
 // } else if(l.front == 0) {
 // return(strip_zeroes(pop_front(l), N-1));
 // } else {
-// return(inconsistant);
+// return(inconsistent);
 // }
 // }
 
@@ -976,7 +976,7 @@
 struct strip_zeroes_func {
     template<class L, int N>
     struct apply {
- typedef inconsistant type;
+ typedef inconsistent type;
     };
 };
 

Modified: sandbox/units/boost/units/dim.hpp
==============================================================================
--- sandbox/units/boost/units/dim.hpp (original)
+++ sandbox/units/boost/units/dim.hpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -54,17 +54,6 @@
     typedef V value_type;
 };
 
-///// Check that a type is a valid @c dim.
-//template<typename T>
-//struct is_dim :
-// public mpl::false_
-//{ };
-//
-//template<typename T,typename V>
-//struct is_dim< dim<T,V> > :
-// public mpl::true_
-//{ };
-
 } // namespace units
 
 } // namespace boost
@@ -81,6 +70,8 @@
 
 namespace mpl {
 
+// define MPL operators acting on dim<T,V>
+
 template<>
 struct plus_impl<boost::units::detail::dim_tag,boost::units::detail::dim_tag>
 {

Modified: sandbox/units/boost/units/homogeneous_system.hpp
==============================================================================
--- sandbox/units/boost/units/homogeneous_system.hpp (original)
+++ sandbox/units/boost/units/homogeneous_system.hpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -69,7 +69,7 @@
                 L,
                 Dimensions
>::type,
- inconsistant
+ inconsistent
>
> {};
 

Modified: sandbox/units/boost/units/systems/base_units.hpp
==============================================================================
--- sandbox/units/boost/units/systems/base_units.hpp (original)
+++ sandbox/units/boost/units/systems/base_units.hpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -41,35 +41,38 @@
 #include <boost/units/systems/base_units/steradian.hpp>
 #include <boost/units/systems/base_units/yard.hpp>
 
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::foot_base_unit, boost::units::meter_base_unit::unit_type, double, 0.3048);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::inch_base_unit, boost::units::meter_base_unit::unit_type, double, 25.4e-3);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::yard_base_unit, boost::units::meter_base_unit::unit_type, double, 0.9144);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::mile_base_unit, boost::units::meter_base_unit::unit_type, double, 1609.344);
-
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::mile_base_unit, boost::units::yard_base_unit::unit_type, double, 1760.0);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::mile_base_unit, boost::units::foot_base_unit::unit_type, double, 5280.0);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::mile_base_unit, boost::units::inch_base_unit::unit_type, double, 63360.0);
-
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::yard_base_unit, boost::units::foot_base_unit::unit_type, double, 3.0);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::yard_base_unit, boost::units::inch_base_unit::unit_type, double, 36.0);
-
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::foot_base_unit, boost::units::inch_base_unit::unit_type, double, 12.0);
-
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::hour_base_unit, boost::units::minute_base_unit::unit_type, double, 60.0);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::hour_base_unit, boost::units::second_base_unit::unit_type, double, 3600.0);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::minute_base_unit, boost::units::second_base_unit::unit_type, double, 60.0);
-
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::kelvin_base_unit, boost::units::celsius_base_unit::unit_type, one, one());
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::kelvin_base_unit, boost::units::fahrenheit_base_unit::unit_type, double, 9.0/5.0);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::celsius_base_unit, boost::units::fahrenheit_base_unit::unit_type, double, 9.0/5.0);
-
-BOOST_UNITS_DEFINE_AFFINE_CONVERSION(boost::units::kelvin_base_unit::unit_type, boost::units::celsius_base_unit::unit_type, double, -273.15);
-BOOST_UNITS_DEFINE_AFFINE_CONVERSION(boost::units::kelvin_base_unit::unit_type, boost::units::fahrenheit_base_unit::unit_type, double, -273.15 * 9.0 / 5.0 + 32.0);
-BOOST_UNITS_DEFINE_AFFINE_CONVERSION(boost::units::celsius_base_unit::unit_type, boost::units::fahrenheit_base_unit::unit_type, double, 32.0);
-
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::radian_base_unit, boost::units::degree_base_unit::unit_type, double, 180/3.14159265358979323846);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::radian_base_unit, boost::units::gradian_base_unit::unit_type, double, 200/3.14159265358979323846);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::radian_base_unit, boost::units::revolution_base_unit::unit_type, double, 0.5/3.14159265358979323846);
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::degree_base_unit, boost::units::gradian_base_unit::unit_type, double, 10/9.);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::foot_base_unit, boost::units::meter_base_unit::unit_type, double, 0.3048);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::inch_base_unit, boost::units::meter_base_unit::unit_type, double, 25.4e-3);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::meter_base_unit::unit_type, double, 0.9144);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::meter_base_unit::unit_type, double, 1609.344);
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::yard_base_unit::unit_type, double, 1760.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::foot_base_unit::unit_type, double, 5280.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::mile_base_unit, boost::units::inch_base_unit::unit_type, double, 63360.0);
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::foot_base_unit::unit_type, double, 3.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::yard_base_unit, boost::units::inch_base_unit::unit_type, double, 36.0);
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::foot_base_unit, boost::units::inch_base_unit::unit_type, double, 12.0);
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::hour_base_unit, boost::units::minute_base_unit::unit_type, double, 60.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::hour_base_unit, boost::units::second_base_unit::unit_type, double, 3600.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::minute_base_unit, boost::units::second_base_unit::unit_type, double, 60.0);
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::kelvin_base_unit, boost::units::celsius_base_unit::unit_type, one, one());
+BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::kelvin_base_unit::unit_type, boost::units::celsius_base_unit::unit_type, double, -273.15);
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::kelvin_base_unit, boost::units::fahrenheit_base_unit::unit_type, double, 9.0/5.0);
+BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::kelvin_base_unit::unit_type, boost::units::fahrenheit_base_unit::unit_type, double, -273.15 * 9.0 / 5.0 + 32.0);
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::celsius_base_unit, boost::units::fahrenheit_base_unit::unit_type, double, 9.0/5.0);
+BOOST_UNITS_DEFINE_CONVERSION_OFFSET(boost::units::celsius_base_unit::unit_type, boost::units::fahrenheit_base_unit::unit_type, double, 32.0);
+
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::degree_base_unit::unit_type, double, 180/3.14159265358979323846);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::gradian_base_unit::unit_type, double, 200/3.14159265358979323846);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::radian_base_unit, boost::units::revolution_base_unit::unit_type, double, 0.5/3.14159265358979323846);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::degree_base_unit, boost::units::gradian_base_unit::unit_type, double, 10/9.);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::degree_base_unit, boost::units::revolution_base_unit::unit_type, double, 1/360.);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::gradian_base_unit, boost::units::revolution_base_unit::unit_type, double, 1/400.);
 
 #endif // BOOST_UNITS_OTHER_UNITS_HPP_INCLUDED

Modified: sandbox/units/boost/units/systems/other/non_si_units.hpp
==============================================================================
--- sandbox/units/boost/units/systems/other/non_si_units.hpp (original)
+++ sandbox/units/boost/units/systems/other/non_si_units.hpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -26,7 +26,7 @@
 
 #ifdef BOOST_UNITS_DOXYGEN
 ///INTERNAL ONLY
-#define BOOST_UNITS_DEFINE_CONVERSION(name, unit, type, factor)
+#define BOOST_UNITS_DEFINE_CONVERSION_FACTOR(name, unit, type, factor)
 ///INTERNAL ONLY
 #define BOOST_UNITS_DEFAULT_CONVERSION(name, unit)
 #endif
@@ -40,7 +40,7 @@
 } \
 } \
 } \
-BOOST_UNITS_DEFINE_CONVERSION(BOOST_UNITS_NAMESPACE::name, unit, double, factor); \
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(BOOST_UNITS_NAMESPACE::name, unit, double, factor); \
 BOOST_UNITS_DEFAULT_CONVERSION(BOOST_UNITS_NAMESPACE::name, unit)
 
 ///INTERNAL ONLY
@@ -65,7 +65,7 @@
 // units of length
 typedef scaled_base_unit<meter_base_unit, scale<10, static_rational<10> > > angstrom_base_unit;
 typedef scaled_base_unit<meter_base_unit, scale<10, static_rational<15> > > fermi_base_unit;
-typedef scaled_base_unit<meter_base_unit, scale<10, static_rational<6> > > micron_base_unit;
+typedef scaled_base_unit<meter_base_unit, scale<10, static_rational<6> > > micron_base_unit;
 
 // units of mass
 typedef scaled_base_unit<kilogram_base_unit, scale<10, static_rational<3> > > ton_base_unit;

Modified: sandbox/units/boost/units/units_fwd.hpp
==============================================================================
--- sandbox/units/boost/units/units_fwd.hpp (original)
+++ sandbox/units/boost/units/units_fwd.hpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -32,9 +32,10 @@
 template<class T> struct get_dimension;
 template<class T> struct get_system;
 
-template<class Dim,class System, class Enable=void> class unit;
 template<class Y> class absolute;
 
+template<class Dim,class System, class Enable=void> class unit;
+
 template<class BaseUnitTag> struct base_unit_info;
 template<class System> struct dimensionless_unit;
 template<class T> struct is_unit;
@@ -48,6 +49,8 @@
 template<class T,class Dim> struct is_quantity_of_dimension;
 template<class T,class System> struct is_quantity_of_system;
 
+template<class From,class To> struct conversion_helper;
+
 } // namespace units
 
 } // namespace boost

Modified: sandbox/units/libs/units/doc/units.qbk
==============================================================================
--- sandbox/units/libs/units/doc/units.qbk (original)
+++ sandbox/units/libs/units/doc/units.qbk 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -61,7 +61,7 @@
 [def __BOOST_UNITS_STATIC_CONSTANT [macroref BOOST_UNITS_STATIC_CONSTANT]]
 [def __BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSIONS [macroref BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSIONS]]
 
-[def __BOOST_UNITS_DEFINE_CONVERSION [macroref BOOST_UNITS_DEFINE_CONVERSION]]
+[def __BOOST_UNITS_DEFINE_CONVERSION [macroref BOOST_UNITS_DEFINE_CONVERSION_FACTOR]]
 [def __BOOST_UNITS_DEFINE_BASE_CONVERSION [macroref BOOST_UNITS_DEFINE_BASE_CONVERSION]]
 [def __BOOST_UNITS_DEFAULT_CONVERSION [macroref BOOST_UNITS_DEFAULT_CONVERSION]]
 
@@ -445,7 +445,7 @@
 
     struct my_unit_tag : boost::units::base_unit<my_unit_tag, boost::units::force_type, 1> {};
     // define the conversion factor
- BOOST_UNITS_DEFINE_CONVERSION(my_unit_tag, SI::force, double, 3.14159265358979323846);
+ BOOST_UNITS_DEFINE_CONVERSION_FACTOR(my_unit_tag, SI::force, double, 3.14159265358979323846);
     // make conversion to SI the default.
     BOOST_UNITS_DEFAULT_CONVERSION(my_unit_tag, SI::force);
 

Modified: sandbox/units/libs/units/example/complex.cpp
==============================================================================
--- sandbox/units/libs/units/example/complex.cpp (original)
+++ sandbox/units/libs/units/example/complex.cpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -165,16 +165,44 @@
     typedef typename boost::units::multiply_typeof_helper<X,Y>::type type;
     
     return complex<type>(x.real()*y.real()-x.imag()*y.imag(),x.real()*y.imag()+x.imag()*y.real());
+
+// fully correct implementation has more complex return type
+//
+// typedef typename boost::units::multiply_typeof_helper<X,Y>::type xy_type;
+//
+// typedef typename boost::units::add_typeof_helper<xy_type,xy_type>::type xy_plus_xy_type;
+// typedef typename boost::units::subtract_typeof_helper<xy_type,xy_type>::type xy_minus_xy_type;
+//
+// BOOST_STATIC_ASSERT((boost::is_same<xy_plus_xy_type,xy_minus_xy_type>::value == true));
+//
+// return complex<xy_plus_xy_type>(x.real()*y.real()-x.imag()*y.imag(),x.real()*y.imag()+x.imag()*y.real());
 }
 
 template<class X,class Y>
 complex<typename boost::units::divide_typeof_helper<X,Y>::type>
 operator/(const complex<X>& x,const complex<Y>& y)
 {
- typedef typename boost::units::divide_typeof_helper<X,Y>::type type;
-
+ // naive implementation of complex division
+ typedef typename boost::units::divide_typeof_helper<X,Y>::type type;
+
     return complex<type>((x.real()*y.real()+x.imag()*y.imag())/(y.real()*y.real()+y.imag()*y.imag()),
                          (x.imag()*y.real()-x.real()*y.imag())/(y.real()*y.real()+y.imag()*y.imag()));
+
+// fully correct implementation has more complex return type
+//
+// typedef typename boost::units::multiply_typeof_helper<X,Y>::type xy_type;
+// typedef typename boost::units::multiply_typeof_helper<Y,Y>::type yy_type;
+//
+// typedef typename boost::units::add_typeof_helper<xy_type,xy_type>::type xy_plus_xy_type;
+// typedef typename boost::units::subtract_typeof_helper<xy_type,xy_type>::type xy_minus_xy_type;
+//
+// typedef typename boost::units::divide_typeof_helper<xy_plus_xy_type,yy_type>::type xy_plus_xy_over_yy_type;
+// typedef typename boost::units::divide_typeof_helper<xy_minus_xy_type,yy_type>::type xy_minus_xy_over_yy_type;
+//
+// BOOST_STATIC_ASSERT((boost::is_same<xy_plus_xy_over_yy_type,xy_minus_xy_over_yy_type>::value == true));
+//
+// return complex<xy_plus_xy_over_yy_type>((x.real()*y.real()+x.imag()*y.imag())/(y.real()*y.real()+y.imag()*y.imag()),
+// (x.imag()*y.real()-x.real()*y.imag())/(y.real()*y.real()+y.imag()*y.imag()));
 }
 
 template<class Y>
@@ -196,7 +224,7 @@
     return os;
 }
 
-/// specialize power typeof helper
+/// specialize power typeof helper for complex<Y>
 template<class Y,long N,long D>
 struct power_dimof_helper<complex<Y>,static_rational<N,D> >
 {
@@ -212,7 +240,7 @@
     }
 };
 
-/// specialize root typeof helper
+/// specialize root typeof helper for complex<Y>
 template<class Y,long N,long D>
 struct root_typeof_helper<complex<Y>,static_rational<N,D> >
 {

Modified: sandbox/units/libs/units/example/non_base_dimension.cpp
==============================================================================
--- sandbox/units/libs/units/example/non_base_dimension.cpp (original)
+++ sandbox/units/libs/units/example/non_base_dimension.cpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -71,7 +71,7 @@
 
 } // namespace boost
 
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::imperial_gallon_tag, boost::units::us_gallon_tag::unit_type, double, 1.2009499255);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::imperial_gallon_tag, boost::units::us_gallon_tag::unit_type, double, 1.2009499255);
 
 using namespace boost::units;
 

Modified: sandbox/units/libs/units/example/radar_beam_height.cpp
==============================================================================
--- sandbox/units/libs/units/example/radar_beam_height.cpp (original)
+++ sandbox/units/libs/units/example/radar_beam_height.cpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -70,7 +70,7 @@
 
 } // namespace boost
 
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::nautical::length_base_unit, boost::units::meter_base_unit::unit_type, double, 1.852e3);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::nautical::length_base_unit, boost::units::meter_base_unit::unit_type, double, 1.852e3);
 
 namespace boost {
 
@@ -100,7 +100,7 @@
 
 } // namespace boost
 
-BOOST_UNITS_DEFINE_CONVERSION(boost::units::imperial::length_base_unit, boost::units::meter_base_unit::unit_type, double, 1.0/3.28083989501312);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(boost::units::imperial::length_base_unit, boost::units::meter_base_unit::unit_type, double, 1.0/3.28083989501312);
 
 namespace boost {
 

Modified: sandbox/units/libs/units/example/temperature.cpp
==============================================================================
--- sandbox/units/libs/units/example/temperature.cpp (original)
+++ sandbox/units/libs/units/example/temperature.cpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -74,7 +74,7 @@
 
 template<>
 struct is_implicitly_convertible<absolute< unit<temperature_dimension,fahrenheit::system> >,
- absolute< unit<temperature_dimension,SI::system> > > :
+ absolute< unit<temperature_dimension,SI::system> > > :
     public mpl::true_
 { };
 //]
@@ -88,19 +88,19 @@
     std::stringstream sstream1, sstream2;
     
     //[temperature_snippet_3
- quantity<absolute<fahrenheit::temperature> > T1p(32.0*absolute<fahrenheit::temperature>());
+ quantity<absolute<fahrenheit::temperature> > T1p(32.0*absolute<fahrenheit::temperature>());
     quantity<fahrenheit::temperature> T1v(32.0*fahrenheit::degrees);
     
- quantity<absolute<SI::temperature> > T2p(T1p);
- quantity<absolute<SI::temperature> > T3p = T1p;
+ quantity<absolute<SI::temperature> > T2p(T1p);
+ quantity<absolute<SI::temperature> > T3p = T1p;
     quantity<SI::temperature> T2v(T1v);
     quantity<SI::temperature> T3v = T1v;
     //]
 
     typedef conversion_helper<quantity<absolute<fahrenheit::temperature> >,
- quantity<absolute<SI::temperature> > > absolute_conv_type;
- typedef conversion_helper<quantity<fahrenheit::temperature,double>,
- quantity<SI::temperature,double> > relative_conv_type;
+ quantity<absolute<SI::temperature> > > absolute_conv_type;
+ typedef conversion_helper<quantity<fahrenheit::temperature>,
+ quantity<SI::temperature> > relative_conv_type;
     
     sstream1 << T1p << std::endl
               << absolute_conv_type::convert(T1p) << std::endl

Modified: sandbox/units/libs/units/test/test_conversion.cpp
==============================================================================
--- sandbox/units/libs/units/test/test_conversion.cpp (original)
+++ sandbox/units/libs/units/test/test_conversion.cpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -33,7 +33,7 @@
 
 namespace bu = boost::units;
 
-typedef bu::SI::length si_length;
+typedef bu::SI::length si_length;
 typedef bu::SI::time si_time;
 typedef bu::SI::mass si_mass;
 typedef bu::SI::area si_area;
@@ -62,8 +62,6 @@
     BOOST_CHECK((std::abs(a3.value() - 2.0) < .0001));
 
     bu::quantity<mixed_energy_1> e1(2.0 * mixed_energy_1());
-
- //heterogeneous->heterogeneous is broken
     bu::quantity<mixed_energy_2> e2(e1);
 
     BOOST_CHECK((std::abs(e2.value() - 20.0) < .0001));
@@ -73,29 +71,14 @@
     bu::quantity<mixed_energy_2> e4(e3);
     BOOST_CHECK((std::abs(e4.value() - 20.0) < .0001));
 
-
-
     bu::quantity<bu::CGS::force> F0 = 20 * bu::CGS::dyne;
     BOOST_CHECK((std::abs(F0.value() - 20.0) < .0001));
 
- //deprecated
- //bu::quantity<bu::SI::force> F1 = bu::quantity_cast<bu::quantity<bu::SI::force> >(F0);
- //BOOST_CHECK((std::abs(F1.value() - 2.0e-4) < .000000001));
-
- //deprecated
- //bu::quantity<bu::SI::force> F2 = bu::quantity_cast<bu::quantity<bu::SI::force> >(20 * bu::CGS::dyne);
- //BOOST_CHECK((std::abs(F2.value() - 2.0e-4) < .000000001));
-
     bu::quantity<bu::SI::force> F3(F0);
     BOOST_CHECK((std::abs(F3.value() - 2.0e-4) < .000000001));
- //quantity<SI::force> F4 = F0;
 
     bu::quantity<bu::SI::force> F5(20 * bu::CGS::dyne);
     BOOST_CHECK((std::abs(F5.value() - 2.0e-4) < .000000001));
-
- //quantity<SI::force> F6 = 20 * CGS::dyne;
-
-
 
     bu::quantity<bu::SI::dimensionless> dimensionless_test1(1.0*bu::CGS::dyne/bu::SI::newton);
     BOOST_CHECK(dimensionless_test1 == 1e-5);

Modified: sandbox/units/libs/units/test/test_default_conversion.cpp
==============================================================================
--- sandbox/units/libs/units/test/test_default_conversion.cpp (original)
+++ sandbox/units/libs/units/test/test_default_conversion.cpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -41,7 +41,7 @@
 BOOST_UNITS_DEFINE_BASE_CONVERSION(unit2_tag, unit3_tag, double, 3.0);
 
 typedef boost::units::multiply_typeof_helper<unit3_tag::unit_type, unit4_tag::unit_type>::type unit34_type;
-BOOST_UNITS_DEFINE_CONVERSION(unit5_tag, unit34_type , double, 5.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(unit5_tag, unit34_type , double, 5.0);
 
 BOOST_UNITS_DEFAULT_CONVERSION(unit1_tag, unit2_tag::unit_type);
 

Modified: sandbox/units/libs/units/tutorial/tutorial_1.cpp
==============================================================================
--- sandbox/units/libs/units/tutorial/tutorial_1.cpp (original)
+++ sandbox/units/libs/units/tutorial/tutorial_1.cpp 2007-10-18 20:25:44 EDT (Thu, 18 Oct 2007)
@@ -10,14 +10,152 @@
 
 #include <iostream>
 
+#include <boost/units/units_fwd.hpp>
+
 #include <boost/units/base_dimension.hpp>
+#include <boost/units/base_unit.hpp>
 #include <boost/units/derived_dimension.hpp>
+#include <boost/units/make_system.hpp>
 #include <boost/units/io.hpp>
 #include <boost/units/quantity.hpp>
 #include <boost/units/static_constant.hpp>
 #include <boost/units/unit.hpp>
+
+namespace boost {
+
+namespace units {
+
+struct length_base_dimension : boost::units::base_dimension<length_base_dimension,1> { }; ///> base dimension of length
+struct time_base_dimension : boost::units::base_dimension<time_base_dimension,3> { }; ///> base dimension of time
+
+typedef length_base_dimension::dimension_type length_dimension;
+typedef time_base_dimension::dimension_type time_dimension;
+
+struct length1_base_unit : base_unit<length1_base_unit,length_dimension,1>
+{
+ static std::string name() { return "length 1"; }
+ static std::string symbol() { return "l1"; }
+};
+
+struct length2_base_unit : base_unit<length2_base_unit,length_dimension,2>
+{
+ static std::string name() { return "length2"; }
+ static std::string symbol() { return "l2"; }
+};
+
+struct time1_base_unit : base_unit<time1_base_unit,time_dimension,3>
+{
+ static std::string name() { return "time1"; }
+ static std::string symbol() { return "t1"; }
+};
+
+struct time2_base_unit : base_unit<time2_base_unit,time_dimension,4>
+{
+ static std::string name() { return "time2"; }
+ static std::string symbol() { return "t2"; }
+};
+
+namespace s1 {
+
+typedef make_system<length1_base_unit,time1_base_unit>::type system;
+
+/// unit typedefs
+typedef unit<dimensionless_type,system> dimensionless;
+
+typedef unit<length_dimension,system> length;
+typedef unit<time_dimension,system> time;
+
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(length1,length);
+BOOST_UNITS_STATIC_CONSTANT(time1,time);
+
+} // namespace s1
+
+namespace s2 {
+
+typedef make_system<length2_base_unit,time2_base_unit>::type system;
+
+/// unit typedefs
+typedef unit<dimensionless_type,system> dimensionless;
+
+typedef unit<length_dimension,system> length;
+typedef unit<time_dimension,system> time;
+
+/// unit constants
+BOOST_UNITS_STATIC_CONSTANT(length2,length);
+BOOST_UNITS_STATIC_CONSTANT(time2,time);
+
+} // namespace s2
+
+template<class X,class Y>
+struct conversion_helper< quantity<s1::length,X>,quantity<s2::length,Y> >
+{
+ static quantity<s2::length,Y> convert(const quantity<s1::length,X>& source)
+ {
+ return quantity<s2::length,Y>::from_value(2.5*source.value());
+ }
+};
+
+template<class X,class Y>
+struct conversion_helper< quantity<s2::length,X>,quantity<s1::length,Y> >
+{
+ static quantity<s1::length,Y> convert(const quantity<s2::length,X>& source)
+ {
+ return quantity<s1::length,Y>::from_value((1.0/2.5)*source.value());
+ }
+};
+
+template<class X,class Y>
+struct conversion_helper< quantity<s1::time,X>,quantity<s2::time,Y> >
+{
+ static quantity<s2::time,Y> convert(const quantity<s1::time,X>& source)
+ {
+ return quantity<s2::time,Y>::from_value(0.5*source.value());
+ }
+};
+
+} // namespace units
+
+} // namespace boost
+
+int main(void)
+{
+ using namespace boost::units;
+
+ quantity<s1::length,float> l1(1.0*s1::length1);
+ quantity<s2::length,double> l2(1.5*l1);
+ quantity<s1::length,float> l3(2.0*l2/3.0);
+
+ quantity<s1::time,float> t1(1.0*s1::time1);
+ quantity<s2::time,double> t2(1.5*t1);
+// quantity<s1::time,float> t3(2.0*t2/3.0);
+
+ return 0;
+}
+
+/*
+// mcs::units - A C++ library for zero-overhead dimensional analysis and
+// unit/quantity manipulation and conversion
+//
+// Copyright (C) 2003-2007 Matthias Christian Schabel
+// Copyright (C) 2007 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)
+
+#include <iostream>
+
+#include <boost/units/units_fwd.hpp>
+
+#include <boost/units/base_dimension.hpp>
 #include <boost/units/base_unit.hpp>
+#include <boost/units/derived_dimension.hpp>
 #include <boost/units/make_system.hpp>
+#include <boost/units/io.hpp>
+#include <boost/units/quantity.hpp>
+#include <boost/units/static_constant.hpp>
+#include <boost/units/unit.hpp>
 
 namespace boost {
 
@@ -27,18 +165,31 @@
 struct mass_base_dimension : boost::units::base_dimension<mass_base_dimension,2> { }; ///> base dimension of mass
 struct time_base_dimension : boost::units::base_dimension<time_base_dimension,3> { }; ///> base dimension of time
 
-typedef length_base_dimension::type length_dimension;
-typedef mass_base_dimension::type mass_dimension;
-typedef time_base_dimension::type time_dimension;
-
-struct centimeter_base_unit : base_unit<centimeter_base_unit,length_dimension,1> { };
-struct gram_base_unit : base_unit<gram_base_unit,mass_dimension,2> { };
-struct second_base_unit : base_unit<second_base_unit,time_dimension,3> { };
+typedef length_base_dimension::dimension_type length_dimension;
+typedef mass_base_dimension::dimension_type mass_dimension;
+typedef time_base_dimension::dimension_type time_dimension;
+
+struct centimeter_base_unit : base_unit<centimeter_base_unit,length_dimension,1>
+{
+ static std::string name() { return "centimeter"; }
+ static std::string symbol() { return "cm"; }
+};
+
+struct gram_base_unit : base_unit<gram_base_unit,mass_dimension,2>
+{
+ static std::string name() { return "gram"; }
+ static std::string symbol() { return "g"; }
+};
+
+struct second_base_unit : base_unit<second_base_unit,time_dimension,3>
+{
+ static std::string name() { return "second"; }
+ static std::string symbol() { return "s"; }
+};
 
 namespace CG {
 
-typedef make_system<centimeter_base_unit,
- gram_base_unit>::type system;
+typedef make_system<centimeter_base_unit,gram_base_unit>::type system;
 
 /// unit typedefs
 typedef unit<dimensionless_type,system> dimensionless;
@@ -50,13 +201,11 @@
 BOOST_UNITS_STATIC_CONSTANT(centimeter,length);
 BOOST_UNITS_STATIC_CONSTANT(gram,mass);
 
-} // namespace CGS
+} // namespace CG
 
 namespace CGS {
 
-typedef make_system<centimeter_base_unit,
- gram_base_unit,
- second_base_unit>::type system;
+typedef make_system<centimeter_base_unit,gram_base_unit,second_base_unit>::type system;
 
 /// unit typedefs
 typedef unit<dimensionless_type,system> dimensionless;
@@ -129,24 +278,6 @@
 
 } // namespace esu
 
-template<> struct base_unit_info<centimeter_base_unit>
-{
- static std::string name() { return "centimeter"; }
- static std::string symbol() { return "cm"; }
-};
-
-template<> struct base_unit_info<gram_base_unit>
-{
- static std::string name() { return "gram"; }
- static std::string symbol() { return "g"; }
-};
-
-template<> struct base_unit_info<second_base_unit>
-{
- static std::string name() { return "second"; }
- static std::string symbol() { return "s"; }
-};
-
 template<class Y>
 quantity<esu::force,Y> coulombLaw(const quantity<esu::charge,Y>& q1,
                                   const quantity<esu::charge,Y>& q2,
@@ -162,7 +293,6 @@
 int main(void)
 {
     using namespace boost::units;
- using namespace boost::units::CGS;
 
     quantity<CG::length> cg_length(1.0*CG::centimeter);
     quantity<CGS::length> cgs_length(1.0*CGS::centimeter);
@@ -181,4 +311,4 @@
     
     return 0;
 }
-
+*/


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