Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-13 13:23:38


Author: steven_watanabe
Date: 2008-05-13 13:23:37 EDT (Tue, 13 May 2008)
New Revision: 45334
URL: http://svn.boost.org/trac/boost/changeset/45334

Log:
Removed old conversion macros
Text files modified:
   sandbox/units/boost/units/conversion.hpp | 44 +++++++++++----------------------------
   sandbox/units/libs/units/example/conversion_factor.cpp | 2 -
   sandbox/units/libs/units/example/runtime_conversion_factor.cpp | 9 +++----
   sandbox/units/libs/units/test/test_default_conversion.cpp | 4 +-
   4 files changed, 19 insertions(+), 40 deletions(-)

Modified: sandbox/units/boost/units/conversion.hpp
==============================================================================
--- sandbox/units/boost/units/conversion.hpp (original)
+++ sandbox/units/boost/units/conversion.hpp 2008-05-13 13:23:37 EDT (Tue, 13 May 2008)
@@ -49,28 +49,6 @@
 
 #endif
 
-/// This macro is deprecated. Please use BOOST_UNITS_DEFINE_CONVERSION_FACTOR.
-#define BOOST_UNITS_DEFINE_BASE_CONVERSION BOOST_UNITS_DEFINE_CONVERSION_FACTOR
-
-/// 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 { \
- template<BOOST_PP_SEQ_ENUM(Params)> \
- struct base_unit_converter< \
- Source, \
- BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Destination, typename Source::dimension_type)\
- > \
- { \
- typedef type_ type; \
- static type value() { return(value_); } \
- }; \
- } \
- } \
- void boost_units_require_semicolon()
-
 /// Defines the conversion factor from a base unit to any unit
 /// or to another base unit with the correct dimensions. Uses
 /// of this macro must appear at global scope.
@@ -99,19 +77,23 @@
     } \
     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. Neither unit may be scaled.
-/// 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.
+/// Defines the conversion factor from a base unit to any other base
+/// unit with the same dimensions. Params should be a Boost.Preprocessor
+/// Seq of template parameters, such as (class T1)(class T2)
+/// All uses of must appear at global scope. The reverse conversion will
+/// be defined automatically. This macro is a little dangerous, because,
+/// unlike the non-template form, it will silently fail if either base
+/// unit is scaled. This is probably not an issue if both the source
+/// and destination types depend on the template parameters, but be aware
+/// that a generic conversion to kilograms is not going to work.
 #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> \
+ struct base_unit_converter< \
+ Source, \
+ BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Destination, typename Source::dimension_type)\
+ > \
     { \
         typedef type_ type; \
         static type value() { return(value_); } \

Modified: sandbox/units/libs/units/example/conversion_factor.cpp
==============================================================================
--- sandbox/units/libs/units/example/conversion_factor.cpp (original)
+++ sandbox/units/libs/units/example/conversion_factor.cpp 2008-05-13 13:23:37 EDT (Tue, 13 May 2008)
@@ -43,8 +43,6 @@
 #include <boost/units/systems/si/momentum.hpp>
 #include <boost/units/systems/cgs/momentum.hpp>
 
-#include <boost/units/systems/other/non_si_units.hpp>
-
 int main()
 {
     using namespace boost;

Modified: sandbox/units/libs/units/example/runtime_conversion_factor.cpp
==============================================================================
--- sandbox/units/libs/units/example/runtime_conversion_factor.cpp (original)
+++ sandbox/units/libs/units/example/runtime_conversion_factor.cpp 2008-05-13 13:23:37 EDT (Tue, 13 May 2008)
@@ -49,11 +49,10 @@
     conversion_factors[to][from] = 1.0 / value;
 }
 
-BOOST_UNITS_DEFINE_BASE_CONVERSION_TEMPLATE((long N1)(long N2),
- currency_base_unit<N1>,
- currency_base_unit<N2>,
- double,
- get_conversion_factor(N1, N2));
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR_TEMPLATE((long N1)(long N2),
+ currency_base_unit<N1>,
+ currency_base_unit<N2>,
+ double, get_conversion_factor(N1, N2));
 
 //]
 

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 2008-05-13 13:23:37 EDT (Tue, 13 May 2008)
@@ -36,9 +36,9 @@
 
 struct unit5_tag : boost::units::base_unit<unit5_tag, dimension12, 5> {};
 
-BOOST_UNITS_DEFINE_BASE_CONVERSION(unit1_tag, unit2_tag, double, 2.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(unit1_tag, unit2_tag, double, 2.0);
 
-BOOST_UNITS_DEFINE_BASE_CONVERSION(unit2_tag, unit3_tag, double, 3.0);
+BOOST_UNITS_DEFINE_CONVERSION_FACTOR(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_FACTOR(unit5_tag, unit34_type , double, 5.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