Boost logo

Boost-Commit :

From: steven_watanabe_at_[hidden]
Date: 2007-05-30 18:31:26


Author: steven_watanabe
Date: 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
New Revision: 4370
URL: http://svn.boost.org/trac/boost/changeset/4370

Log:
Lots of little fixes

Added:
   sandbox/units/libs/units/test/test_absolute.cpp
Text files modified:
   sandbox/units/boost/units/absolute.hpp | 53 ++++++++++++++++++++++++--
   sandbox/units/boost/units/conversion.hpp | 7 +++
   sandbox/units/boost/units/get_dimension.hpp | 7 +++
   sandbox/units/boost/units/get_system.hpp | 7 +++
   sandbox/units/boost/units/heterogeneous_system.hpp | 20 ++++++++++
   sandbox/units/boost/units/is_quantity_of_dimension.hpp | 7 ++-
   sandbox/units/boost/units/is_quantity_of_system.hpp | 9 ++--
   sandbox/units/boost/units/is_unit_of_dimension.hpp | 5 ++
   sandbox/units/boost/units/is_unit_of_system.hpp | 5 ++
   sandbox/units/boost/units/make_system.hpp | 4 +-
   sandbox/units/boost/units/systems/base_units.hpp | 80 ++++++++++++++++++++++++++++------------
   sandbox/units/boost/units/unit.hpp | 4 +-
   sandbox/units/boost/units/units_fwd.hpp | 5 +-
   sandbox/units/libs/units/test/Jamfile.v2 | 1
   14 files changed, 169 insertions(+), 45 deletions(-)

Modified: sandbox/units/boost/units/absolute.hpp
==============================================================================
--- sandbox/units/boost/units/absolute.hpp (original)
+++ sandbox/units/boost/units/absolute.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -15,13 +15,18 @@
 
 #include <boost/type_traits/is_base_and_derived.hpp>
 
+#include <boost/units/config.hpp>
 #include <boost/units/conversion.hpp>
 
 namespace boost {
 
 namespace units {
 
-template<class Y = double>
+/// A wrapper to represent absolute units. Intended
+/// originally for temperatures, this template causes
+/// absolute<T> +/- T -> absolute<T>
+/// absolute<T> - absolute<T> -> T
+template<class Y>
 class absolute
 {
     public:
@@ -43,12 +48,29 @@
         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 {};
 
@@ -106,7 +128,15 @@
     }
 };
 
-// a macro for consistancy
+/// 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_tag, fahrenheit_tag::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 {\
@@ -119,24 +149,28 @@
     }\
     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)
 {
- return absolute<Y>(aval.value()+rval.value());
+ return absolute<Y>(aval.value()+rval);
 }
 
+/// add a relative value to an absolute one
 template<class Y>
 absolute<Y> operator+(const Y& rval,const absolute<Y>& aval)
 {
- return absolute<Y>(aval.value()+rval.value());
+ return absolute<Y>(aval.value()+rval);
 }
 
+/// subtract a relative value from an absolute one
 template<class Y>
 absolute<Y> operator-(const absolute<Y>& aval,const Y& rval)
 {
- return absolute<Y>(aval.value()-rval.value());
+ return absolute<Y>(aval.value()-rval);
 }
 
+/// subtracting two absolutes gives a difference (Like pointers)
 template<class Y>
 Y operator-(const absolute<Y>& aval1,const absolute<Y>& aval2)
 {
@@ -157,11 +191,20 @@
     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>
 quantity<absolute<unit<D, S> >, T> operator*(const T& t, const absolute<unit<D, S> >&) {
     return(quantity<absolute<unit<D, S> >, T>::from_value(t));
 }
+/// multiplying an absolute unit by a scalar gives a quantity
+/// just like an ordinary unit
+template<class D, class S, class T>
+quantity<absolute<unit<D, S> >, T> operator*(const absolute<unit<D, S> >&, const T& t) {
+ return(quantity<absolute<unit<D, S> >, T>::from_value(t));
+}
 
+/// Print an absolute unit
 template<class Y>
 std::ostream& operator<<(std::ostream& os,const absolute<Y>& aval)
 {

Modified: sandbox/units/boost/units/conversion.hpp
==============================================================================
--- sandbox/units/boost/units/conversion.hpp (original)
+++ sandbox/units/boost/units/conversion.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -120,7 +120,7 @@
         typedef base_unit_converter<Destination, typename Source::unit_type> inverse;
         typedef typename inverse::type type;
         static type value() {
- return(1/inverse::value());
+ return(one()/inverse::value());
         }
     };
 };
@@ -159,6 +159,11 @@
> : detail::inverse_base_unit_converter_impl<detail::use_inverse_conversion<Source, Dest>::value, boost::is_same<Source, Dest>::value>::template apply<Source, Dest> {
 };
 
+/// 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 {\

Modified: sandbox/units/boost/units/get_dimension.hpp
==============================================================================
--- sandbox/units/boost/units/get_dimension.hpp (original)
+++ sandbox/units/boost/units/get_dimension.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -24,6 +24,13 @@
     typedef Dim type;
 };
 
+/// get the dimension of an absolute unit
+template<class Unit>
+struct get_dimension< absolute<Unit> >
+{
+ typedef typename get_dimension<Unit>::type type;
+};
+
 /// get the dimension of a quantity
 template<class Unit,class Y>
 struct get_dimension< quantity<Unit,Y> >

Modified: sandbox/units/boost/units/get_system.hpp
==============================================================================
--- sandbox/units/boost/units/get_system.hpp (original)
+++ sandbox/units/boost/units/get_system.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -24,6 +24,13 @@
     typedef System type;
 };
 
+/// get the system of an absolute unit
+template<class Unit>
+struct get_system< absolute<Unit> >
+{
+ typedef typename get_system<Unit>::type type;
+};
+
 /// get the system of a quantity
 template<class Unit,class Y>
 struct get_system< quantity<Unit,Y> >

Modified: sandbox/units/boost/units/heterogeneous_system.hpp
==============================================================================
--- sandbox/units/boost/units/heterogeneous_system.hpp (original)
+++ sandbox/units/boost/units/heterogeneous_system.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -20,6 +20,7 @@
 #include <boost/mpl/next.hpp>
 #include <boost/mpl/deref.hpp>
 
+#include <boost/units/config.hpp>
 #include <boost/units/static_rational.hpp>
 #include <boost/units/dimension.hpp>
 #include <boost/units/scaled_base_unit.hpp>
@@ -73,6 +74,25 @@
     typedef Exponent value_type;
 };
 
+} // namespace units
+
+} // namespace boost
+
+
+#if BOOST_UNITS_HAS_BOOST_TYPEOF
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::heterogeneous_system_pair, (class)(class))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::heterogeneous_system, (class))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::heterogeneous_system_dim, (class)(class))
+
+#endif
+
+namespace boost {
+
+namespace units {
+
 namespace detail {
 
 template<class Unit1, class Exponent1, class Unit2, class Exponent2>

Modified: sandbox/units/boost/units/is_quantity_of_dimension.hpp
==============================================================================
--- sandbox/units/boost/units/is_quantity_of_dimension.hpp (original)
+++ sandbox/units/boost/units/is_quantity_of_dimension.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -13,6 +13,7 @@
 
 #include <boost/mpl/bool.hpp>
 #include <boost/units/units_fwd.hpp>
+#include <boost/units/is_unit_of_dimension.hpp>
 
 namespace boost {
 
@@ -24,9 +25,9 @@
     public mpl::false_
 { };
 
-template<class Dim,class System,class Y>
-struct is_quantity_of_dimension< quantity< unit<Dim,System>,Y>,Dim > :
- public mpl::true_
+template<class Unit,class Y,class Dim>
+struct is_quantity_of_dimension< quantity< Unit,Y>,Dim > :
+ public is_unit_of_dimension<Unit, Dim>
 { };
 
 } // namespace units

Modified: sandbox/units/boost/units/is_quantity_of_system.hpp
==============================================================================
--- sandbox/units/boost/units/is_quantity_of_system.hpp (original)
+++ sandbox/units/boost/units/is_quantity_of_system.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -13,6 +13,7 @@
 
 #include <boost/mpl/bool.hpp>
 #include <boost/units/units_fwd.hpp>
+#include <boost/units/is_unit_of_system.hpp>
 
 namespace boost {
 
@@ -24,11 +25,9 @@
     public mpl::false_
 { };
 
-template<class Dim,
- class System,
- class Y>
-struct is_quantity_of_system< quantity< unit<Dim,System>,Y>,System > :
- public mpl::true_
+template<class Unit,class Y,class System>
+struct is_quantity_of_system< quantity< Unit,Y>,System > :
+ public is_unit_of_system<Unit, System>
 { };
 
 } // namespace units

Modified: sandbox/units/boost/units/is_unit_of_dimension.hpp
==============================================================================
--- sandbox/units/boost/units/is_unit_of_dimension.hpp (original)
+++ sandbox/units/boost/units/is_unit_of_dimension.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -29,6 +29,11 @@
     public mpl::true_
 { };
 
+template<class Dim,class System>
+struct is_unit_of_dimension< absolute<unit<Dim,System> >,Dim > :
+ public mpl::true_
+{ };
+
 } // namespace units
 
 } // namespace boost

Modified: sandbox/units/boost/units/is_unit_of_system.hpp
==============================================================================
--- sandbox/units/boost/units/is_unit_of_system.hpp (original)
+++ sandbox/units/boost/units/is_unit_of_system.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -28,6 +28,11 @@
 struct is_unit_of_system< unit<Dim,System>,System > :
     public mpl::true_
 { };
+
+template<class Dim,class System>
+struct is_unit_of_system< absolute<unit<Dim,System> >,System > :
+ public mpl::true_
+{ };
 
 } // namespace units
 

Modified: sandbox/units/boost/units/make_system.hpp
==============================================================================
--- sandbox/units/boost/units/make_system.hpp (original)
+++ sandbox/units/boost/units/make_system.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -91,12 +91,12 @@
 
 template<>
 struct make_system<> {
- typedef homogeneous_system<mpl::list0<> > type;
+ typedef homogeneous_system<dimensionless_type> type;
 };
 
 template<class T0>
 struct make_system<T0> {
- typedef homogeneous_system<typename detail::bubble_sort<mpl::list1<T0> >::type> type;
+ typedef homogeneous_system<dimension_list<T0, dimensionless_type> > type;
 };
 
 template<class T0, class T1>

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-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -23,93 +23,108 @@
 
 namespace units {
 
-struct meter_tag : public base_unit<meter_tag, length_type, -20> {
+struct meter_tag : public base_unit<meter_tag, length_type, -20>
+{
     static std::string name() { return("meter"); }
     static std::string symbol() { return("m"); }
 };
-struct foot_tag : public base_unit<foot_tag, length_type, -19> {
+struct foot_tag : public base_unit<foot_tag, length_type, -19>
+{
     static std::string name() { return("foot"); }
     static std::string symbol() { return("ft"); }
 };
-struct inch_tag : public base_unit<inch_tag, length_type, -18> {
+struct inch_tag : public base_unit<inch_tag, length_type, -18>
+{
     static std::string name() { return("inch"); }
     static std::string symbol() { return("in"); }
 };
-struct yard_tag : public base_unit<yard_tag, length_type, -17> {
+struct yard_tag : public base_unit<yard_tag, length_type, -17>
+{
     static std::string name() { return("yard"); }
     static std::string symbol() { return("yd"); }
 };
-struct mile_tag : public base_unit<mile_tag, length_type, -16> {
+struct mile_tag : public base_unit<mile_tag, length_type, -16>
+{
     static std::string name() { return("mile"); }
     static std::string symbol() { return("mi"); }
 };
 typedef scaled_base_unit<meter_tag, scale<10, static_rational<-2> > > centimeter_tag;
 
-struct gram_tag : public base_unit<gram_tag, mass_type, -15> {
+struct gram_tag : public base_unit<gram_tag, mass_type, -15>
+{
     static std::string name() { return("gram"); }
     static std::string symbol() { return("g"); }
 };
 typedef scaled_base_unit<gram_tag, scale<10, static_rational<3> > > kilogram_tag;
 
-struct second_tag : public base_unit<second_tag, time_type, -14> {
+struct second_tag : public base_unit<second_tag, time_type, -14>
+{
     static std::string name() { return("second"); }
     static std::string symbol() { return("s"); }
 };
-struct minute_tag : public base_unit<minute_tag, time_type, -13> {
+struct minute_tag : public base_unit<minute_tag, time_type, -13>
+{
     static std::string name() { return("minute"); }
     static std::string symbol() { return("min"); }
 };
-struct hour_tag : public base_unit<hour_tag, time_type, -12> {
+struct hour_tag : public base_unit<hour_tag, time_type, -12>
+{
     static std::string name() { return("foot"); }
     static std::string symbol() { return("ft"); }
 };
 
-struct ampere_tag : public base_unit<ampere_tag, current_type, -11> {
+struct ampere_tag : public base_unit<ampere_tag, current_type, -11>
+{
     static std::string name() { return("ampere"); }
     static std::string symbol() { return("A"); }
 };
-struct biot_tag : public base_unit<biot_tag, current_type, -10> {
- static std::string name() { return("biot"); }
- //static std::string symbol() { return(""); }
-};
 
-struct kelvin_tag : public base_unit<kelvin_tag, temperature_type, -9> {
+struct kelvin_tag : public base_unit<kelvin_tag, temperature_type, -9>
+{
     static std::string name() { return("kelvin"); }
     static std::string symbol() { return("K"); }
 };
-struct celsius_tag : public base_unit<celsius_tag, temperature_type, -8> {
+struct celsius_tag : public base_unit<celsius_tag, temperature_type, -8>
+{
     static std::string name() { return("celsius"); }
     static std::string symbol() { return("C"); }
 };
-struct fahrenheit_tag : public base_unit<fahrenheit_tag, temperature_type, -7> {
+struct fahrenheit_tag : public base_unit<fahrenheit_tag, temperature_type, -7>
+{
     static std::string name() { return("fahrenheit"); }
     static std::string symbol() { return("F"); }
 };
 
-struct mole_tag : public base_unit<mole_tag, amount_type, -6> {
+struct mole_tag : public base_unit<mole_tag, amount_type, -6>
+{
     static std::string name() { return("mole"); }
     static std::string symbol() { return("mol"); }
 };
 
-struct candela_tag : public base_unit<candela_tag, luminous_intensity_type, -5> {
+struct candela_tag : public base_unit<candela_tag, luminous_intensity_type, -5>
+{
     static std::string name() { return("candela"); }
     static std::string symbol() { return("cd"); }
 };
 
-struct radian_tag : public base_unit<radian_tag, plane_angle_type, -4> {
+struct radian_tag : public base_unit<radian_tag, plane_angle_type, -4>
+{
     static std::string name() { return("radian"); }
     static std::string symbol() { return("rad"); }
 };
-struct degree_tag : public base_unit<degree_tag, plane_angle_type, -3> {
+struct degree_tag : public base_unit<degree_tag, plane_angle_type, -3>
+{
     static std::string name() { return("degree"); }
     static std::string symbol() { return("deg"); }
 };
-struct gradian_tag : public base_unit<gradian_tag, plane_angle_type, -2> {
+struct gradian_tag : public base_unit<gradian_tag, plane_angle_type, -2>
+{
     static std::string name() { return("gradian"); }
     static std::string symbol() { return("grad"); }
 };
 
-struct steradian_tag : public base_unit<steradian_tag, solid_angle_type, -1> {
+struct steradian_tag : public base_unit<steradian_tag, solid_angle_type, -1>
+{
     static std::string name() { return("steradian"); }
     static std::string symbol() { return("sr"); }
 };
@@ -118,6 +133,24 @@
 
 }
 
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::meter_tag, boost::units::foot_tag::unit_type, double, 0.3048);
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::meter_tag, boost::units::inch_tag::unit_type, double, 25.4e-3);
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::meter_tag, boost::units::yard_tag::unit_type, double, 0.9144);
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::meter_tag, boost::units::mile_tag::unit_type, double, 1609.344);
+
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::mile_tag, boost::units::yard_tag::unit_type, double, 1760.0);
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::mile_tag, boost::units::foot_tag::unit_type, double, 5280.0);
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::mile_tag, boost::units::inch_tag::unit_type, double, 63360.0);
+
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::yard_tag, boost::units::foot_tag::unit_type, double, 3.0);
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::yard_tag, boost::units::inch_tag::unit_type, double, 36.0);
+
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::foot_tag, boost::units::inch_tag::unit_type, double, 12.0);
+
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::hour_tag, boost::units::minute_tag::unit_type, double, 60.0);
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::hour_tag, boost::units::second_tag::unit_type, double, 3600.0);
+BOOST_UNITS_DEFINE_CONVERSION(boost::units::minute_tag, boost::units::second_tag::unit_type, double, 60.0);
+
 BOOST_UNITS_DEFINE_CONVERSION(boost::units::kelvin_tag, boost::units::celsius_tag::unit_type, one, one());
 BOOST_UNITS_DEFINE_CONVERSION(boost::units::kelvin_tag, boost::units::fahrenheit_tag::unit_type, double, 9.0/5.0);
 BOOST_UNITS_DEFINE_CONVERSION(boost::units::celsius_tag, boost::units::fahrenheit_tag::unit_type, double, 9.0/5.0);
@@ -147,7 +180,6 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::units::hour_tag)
 
 BOOST_TYPEOF_REGISTER_TYPE(boost::units::ampere_tag)
-BOOST_TYPEOF_REGISTER_TYPE(boost::units::biot_tag)
 
 BOOST_TYPEOF_REGISTER_TYPE(boost::units::kelvin_tag)
 BOOST_TYPEOF_REGISTER_TYPE(boost::units::fahrenheit_tag)

Modified: sandbox/units/boost/units/unit.hpp
==============================================================================
--- sandbox/units/boost/units/unit.hpp (original)
+++ sandbox/units/boost/units/unit.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -527,7 +527,7 @@
 bool
 operator==(const unit<Dim1,System1>&,const unit<Dim2,System2>&)
 {
- return boost::is_same<Dim1,Dim2>::value && boost::is_same<System1,System2>::value;
+ return boost::is_same<typename reduce_unit<unit<Dim1,System1> >::type, typename reduce_unit<unit<Dim2,System2> >::type>::value;
 }
 
 /// unit runtime @c operator!=
@@ -539,7 +539,7 @@
 bool
 operator!=(const unit<Dim1,System1>&,const unit<Dim2,System2>&)
 {
- return !boost::is_same<Dim1,Dim2>::value || !boost::is_same<System1,System2>::value;
+ return !boost::is_same<typename reduce_unit<unit<Dim1,System1> >::type, typename reduce_unit<unit<Dim2,System2> >::type>::value;
 }
 
 } // namespace units

Modified: sandbox/units/boost/units/units_fwd.hpp
==============================================================================
--- sandbox/units/boost/units/units_fwd.hpp (original)
+++ sandbox/units/boost/units/units_fwd.hpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -15,8 +15,6 @@
 
 namespace units {
 
-template<long N> struct ordinal;
-
 template<typename T,typename V> struct dim;
 template<typename T> struct is_dim;
 
@@ -30,8 +28,9 @@
 template<class T> struct get_system;
 
 template<class Dim,class System> class unit;
+template<class Y> class absolute;
 
-template<class SystemTag,class DimensionTag> struct unit_info;
+template<class BaseUnitTag> struct base_unit_info;
 template<class System> struct dimensionless_unit;
 template<class T> struct is_unit;
 template<class T,class Dim> struct is_unit_of_dimension;

Modified: sandbox/units/libs/units/test/Jamfile.v2
==============================================================================
--- sandbox/units/libs/units/test/Jamfile.v2 (original)
+++ sandbox/units/libs/units/test/Jamfile.v2 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -22,6 +22,7 @@
     [ run test_unit.cpp : : : $(UNIT_REQUIREMENTS) : ]
     [ run test_conversion.cpp : : : $(UNIT_REQUIREMENTS) : ]
     [ run test_base_dimension.cpp : : : $(UNIT_REQUIREMENTS) : ]
+ [ run test_absolute.cpp : : : $(UNIT_REQUIREMENTS) : ]
     [ compile-fail fail_implicit_conversion.cpp : $(UNIT_REQUIREMENTS) : ]
     [ compile-fail fail_quantity_construct.cpp : $(UNIT_REQUIREMENTS) : ]
     [ compile-fail fail_quantity_assign.cpp : $(UNIT_REQUIREMENTS) : ]

Added: sandbox/units/libs/units/test/test_absolute.cpp
==============================================================================
--- (empty file)
+++ sandbox/units/libs/units/test/test_absolute.cpp 2007-05-30 18:31:24 EDT (Wed, 30 May 2007)
@@ -0,0 +1,62 @@
+// 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)
+
+/**
+\file
+
+\brief test_absolute.cpp
+
+\detailed
+Test absolute units.
+
+Output:
+@verbatim
+@endverbatim
+**/
+
+#include <boost/units/quantity.hpp>
+#include <boost/units/absolute.hpp>
+#include <boost/units/unit.hpp>
+#include <boost/units/make_system.hpp>
+#include <boost/units/systems/base_units.hpp>
+
+#include <iostream>
+
+#include <boost/test/minimal.hpp>
+
+#define BOOST_UNITS_CHECK_CLOSE(a, b) (BOOST_CHECK((std::abs((a) - (b)) < .0000001)))
+
+namespace bu = boost::units;
+
+typedef bu::unit<bu::temperature_type,bu::make_system<bu::kelvin_tag>::type> kelvin_type;
+
+typedef bu::unit<bu::temperature_type,bu::make_system<bu::celsius_tag>::type> celsius_type;
+
+typedef bu::unit<bu::temperature_type,bu::make_system<bu::fahrenheit_tag>::type> fahrenheit_type;
+
+int test_main(int,char *[])
+{
+ bu::quantity<bu::absolute<fahrenheit_type> > q1(212.0 * bu::absolute<fahrenheit_type>());
+ bu::quantity<bu::absolute<celsius_type> > q2(0.0 * bu::absolute<celsius_type>());
+ bu::quantity<bu::absolute<fahrenheit_type> > q3(q2);
+ bu::quantity<fahrenheit_type> q4(q1 - q3);
+
+ BOOST_UNITS_CHECK_CLOSE(q4.value(), 180.0);
+
+ bu::quantity<bu::absolute<kelvin_type> > q5(static_cast<bu::quantity<kelvin_type> >(q4) + static_cast<bu::quantity<bu::absolute<kelvin_type> > >(q2));
+
+ BOOST_UNITS_CHECK_CLOSE(q5.value(), 373.15);
+
+ bu::quantity<bu::absolute<fahrenheit_type> > q6(q5);
+
+ BOOST_UNITS_CHECK_CLOSE(q6.value(), 212.0);
+
+ 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