|
Boost-Commit : |
From: steven_at_[hidden]
Date: 2008-05-03 17:13:15
Author: steven_watanabe
Date: 2008-05-03 17:13:15 EDT (Sat, 03 May 2008)
New Revision: 45093
URL: http://svn.boost.org/trac/boost/changeset/45093
Log:
Made BOOST_UNITS_DEFINE_CONVERSION_FACTOR handle all non-template conversions
Text files modified:
sandbox/units/boost/units/conversion.hpp | 46 +++++++++------------------------------
sandbox/units/boost/units/unit.hpp | 1
2 files changed, 12 insertions(+), 35 deletions(-)
Modified: sandbox/units/boost/units/conversion.hpp
==============================================================================
--- sandbox/units/boost/units/conversion.hpp (original)
+++ sandbox/units/boost/units/conversion.hpp 2008-05-03 17:13:15 EDT (Sat, 03 May 2008)
@@ -49,33 +49,8 @@
#endif
-/// 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 { \
- template<> \
- struct select_base_unit_converter< \
- unscale<Source>::type, \
- BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(unscale<Destination>::type, Source::dimension_type)\
- > \
- { \
- typedef Source source_type; \
- typedef BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Destination, Source::dimension_type) destination_type;\
- }; \
- template<> \
- struct base_unit_converter< \
- Source, \
- BOOST_UNITS_MAKE_HETEROGENEOUS_UNIT(Destination, Source::dimension_type)\
- > \
- { \
- typedef type_ type; \
- static type value() { return(value_); } \
- }; \
- } \
- } \
- void boost_units_require_semicolon()
+/// 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.
@@ -97,24 +72,25 @@
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_FACTOR(Source, Destination, type_, value_) \
+/// or to another base unit with the correct dimensions. Uses
+/// of this macro must appear at global scope.
+/// If the destination unit is a base unit or a unit that contains
+/// only one base unit which is raised to the first power (e.g. feet->meters)
+/// the reverse (meters->feet in this example) need not be defined.
+#define BOOST_UNITS_DEFINE_CONVERSION_FACTOR(Source, Destination, type_, value_) \
namespace boost { \
namespace units { \
template<> \
struct select_base_unit_converter< \
unscale<Source>::type, \
- unscale<reduce_unit<Destination>::type>::type \
+ unscale<reduce_unit<Destination::unit_type>::type>::type \
> \
{ \
typedef Source source_type; \
- typedef Destination destination_type; \
+ typedef reduce_unit<Destination::unit_type>::type destination_type; \
}; \
template<> \
- struct base_unit_converter<Source, reduce_unit<Destination>::type> \
+ struct base_unit_converter<Source, reduce_unit<Destination::unit_type>::type> \
{ \
typedef type_ type; \
static type value() { return(value_); } \
Modified: sandbox/units/boost/units/unit.hpp
==============================================================================
--- sandbox/units/boost/units/unit.hpp (original)
+++ sandbox/units/boost/units/unit.hpp 2008-05-03 17:13:15 EDT (Sat, 03 May 2008)
@@ -36,6 +36,7 @@
class unit
{
public:
+ typedef unit<Dim, System> unit_type;
typedef unit<Dim,System> this_type;
typedef Dim dimension_type;
typedef System system_type;
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