|
Boost-Commit : |
From: boost_at_[hidden]
Date: 2008-05-20 17:30:30
Author: matthiasschabel
Date: 2008-05-20 17:30:29 EDT (Tue, 20 May 2008)
New Revision: 45590
URL: http://svn.boost.org/trac/boost/changeset/45590
Log:
change to use base_unit::unit_type and get_system<>
Text files modified:
sandbox/units/libs/units/example/temperature.cpp | 43 ++++++++++++++++++++++++++-------------
1 files changed, 29 insertions(+), 14 deletions(-)
Modified: sandbox/units/libs/units/example/temperature.cpp
==============================================================================
--- sandbox/units/libs/units/example/temperature.cpp (original)
+++ sandbox/units/libs/units/example/temperature.cpp 2008-05-20 17:30:29 EDT (Tue, 20 May 2008)
@@ -20,11 +20,11 @@
Output:
@verbatim
-{ 32 } F
+{ 32 } °F
{ 273.15 } K
{ 273.15 } K
{ 273.15 } K
-[ 32 ] F
+[ 32 ] °F
[ 17.7778 ] K
[ 17.7778 ] K
[ 17.7778 ] K
@@ -38,6 +38,7 @@
#include <sstream>
#include <boost/units/absolute.hpp>
+#include <boost/units/get_system.hpp>
#include <boost/units/io.hpp>
#include <boost/units/unit.hpp>
#include <boost/units/quantity.hpp>
@@ -55,9 +56,13 @@
namespace fahrenheit {
//[temperature_snippet_1
-typedef make_system<boost::units::temperature::fahrenheit_base_unit>::type system;
-
-typedef unit<temperature_dimension,system> temperature;
+// direct method
+//typedef make_system<temperature::fahrenheit_base_unit>::type system;
+//typedef unit<temperature_dimension,system> temperature;
+
+// simpler method for single-unit systems
+typedef temperature::fahrenheit_base_unit::unit_type temperature;
+typedef get_system<temperature>::type system;
BOOST_UNITS_STATIC_CONSTANT(degree,temperature);
BOOST_UNITS_STATIC_CONSTANT(degrees,temperature);
@@ -65,19 +70,29 @@
} // fahrenheit
+//template<>
+//struct is_implicitly_convertible<unit<temperature_dimension,fahrenheit::system>,
+// unit<temperature_dimension,si::system> > :
+// public mpl::true_
+//{ };
+
+//template<>
+//struct is_implicitly_convertible<
+// absolute< unit<temperature_dimension,fahrenheit::system> >,
+// absolute< unit<temperature_dimension,si::system> > > :
+// public mpl::true_
+//{ };
+
//[temperature_snippet_2
template<>
-struct is_implicitly_convertible<unit<temperature_dimension,fahrenheit::system>,
- unit<temperature_dimension,si::system> > :
- public mpl::true_
-{ };
+struct is_implicitly_convertible<
+ fahrenheit::temperature,
+ si::temperature > : public mpl::true_ { };
template<>
-struct is_implicitly_convertible<
- absolute< unit<temperature_dimension,fahrenheit::system> >,
- absolute< unit<temperature_dimension,si::system> > > :
- public mpl::true_
-{ };
+struct is_implicitly_convertible<
+ absolute<fahrenheit::temperature>,
+ absolute<si::temperature> > : public mpl::true_ { };
//]
} // namespace units
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