Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-26 19:20:53


Author: steven_watanabe
Date: 2008-05-26 19:20:52 EDT (Mon, 26 May 2008)
New Revision: 45801
URL: http://svn.boost.org/trac/boost/changeset/45801

Log:
Made it possible for the formatting functions to find the SI and CGS overloads of name_string and symbol_string for scaled units
Text files modified:
   sandbox/units/boost/units/systems/cgs/io.hpp | 33 +++++++++---------
   sandbox/units/boost/units/systems/si/io.hpp | 69 ++++++++++++++++++++-------------------
   2 files changed, 52 insertions(+), 50 deletions(-)

Modified: sandbox/units/boost/units/systems/cgs/io.hpp
==============================================================================
--- sandbox/units/boost/units/systems/cgs/io.hpp (original)
+++ sandbox/units/boost/units/systems/cgs/io.hpp 2008-05-26 19:20:52 EDT (Mon, 26 May 2008)
@@ -12,35 +12,36 @@
 #define BOOST_UNITS_CGS_IO_HPP
 
 #include <boost/units/io.hpp>
+#include <boost/units/reduce_unit.hpp>
 #include <boost/units/systems/cgs.hpp>
 
 namespace boost {
 
 namespace units {
 
-inline std::string name_string(const cgs::acceleration&) { return "galileo"; }
-inline std::string symbol_string(const cgs::acceleration&) { return "Gal"; }
+inline std::string name_string(const reduce_unit<cgs::acceleration>::type&) { return "galileo"; }
+inline std::string symbol_string(const reduce_unit<cgs::acceleration>::type&) { return "Gal"; }
 
-inline std::string name_string(const cgs::current&) { return "biot"; }
-inline std::string symbol_string(const cgs::current&) { return "Bi"; }
+inline std::string name_string(const reduce_unit<cgs::current>::type&) { return "biot"; }
+inline std::string symbol_string(const reduce_unit<cgs::current>::type&) { return "Bi"; }
 
-inline std::string name_string(const cgs::dynamic_viscosity&) { return "poise"; }
-inline std::string symbol_string(const cgs::dynamic_viscosity&) { return "P"; }
+inline std::string name_string(const reduce_unit<cgs::dynamic_viscosity>::type&) { return "poise"; }
+inline std::string symbol_string(const reduce_unit<cgs::dynamic_viscosity>::type&) { return "P"; }
 
-inline std::string name_string(const cgs::energy&) { return "erg"; }
-inline std::string symbol_string(const cgs::energy&) { return "erg"; }
+inline std::string name_string(const reduce_unit<cgs::energy>::type&) { return "erg"; }
+inline std::string symbol_string(const reduce_unit<cgs::energy>::type&) { return "erg"; }
 
-inline std::string name_string(const cgs::force&) { return "dyne"; }
-inline std::string symbol_string(const cgs::force&) { return "dyn"; }
+inline std::string name_string(const reduce_unit<cgs::force>::type&) { return "dyne"; }
+inline std::string symbol_string(const reduce_unit<cgs::force>::type&) { return "dyn"; }
 
-inline std::string name_string(const cgs::kinematic_viscosity&) { return "stoke"; }
-inline std::string symbol_string(const cgs::kinematic_viscosity&) { return "St"; }
+inline std::string name_string(const reduce_unit<cgs::kinematic_viscosity>::type&) { return "stoke"; }
+inline std::string symbol_string(const reduce_unit<cgs::kinematic_viscosity>::type&) { return "St"; }
 
-inline std::string name_string(const cgs::pressure&) { return "barye"; }
-inline std::string symbol_string(const cgs::pressure&) { return "Ba"; }
+inline std::string name_string(const reduce_unit<cgs::pressure>::type&) { return "barye"; }
+inline std::string symbol_string(const reduce_unit<cgs::pressure>::type&) { return "Ba"; }
 
-inline std::string name_string(const cgs::wavenumber&) { return "kayser"; }
-inline std::string symbol_string(const cgs::wavenumber&) { return "K"; }
+inline std::string name_string(const reduce_unit<cgs::wavenumber>::type&) { return "kayser"; }
+inline std::string symbol_string(const reduce_unit<cgs::wavenumber>::type&) { return "K"; }
 
 } // namespace units
 

Modified: sandbox/units/boost/units/systems/si/io.hpp
==============================================================================
--- sandbox/units/boost/units/systems/si/io.hpp (original)
+++ sandbox/units/boost/units/systems/si/io.hpp 2008-05-26 19:20:52 EDT (Mon, 26 May 2008)
@@ -12,6 +12,7 @@
 #define BOOST_UNITS_SI_IO_HPP
 
 #include <boost/units/io.hpp>
+#include <boost/units/reduce_unit.hpp>
 
 #include <boost/units/systems/si.hpp>
 
@@ -20,64 +21,64 @@
 namespace units {
 
 // gray and sievert are indistinguishable
-inline std::string name_string(const si::absorbed_dose&) { return "gray"; }
-inline std::string symbol_string(const si::absorbed_dose&) { return "Gy"; }
+inline std::string name_string(const reduce_unit<si::absorbed_dose>::type&) { return "gray"; }
+inline std::string symbol_string(const reduce_unit<si::absorbed_dose>::type&) { return "Gy"; }
 
 // activity and frequency are indistinguishable - would need a "decays" base unit
 //inline std::string name_string(const si::activity&) { return "becquerel"; }
 //inline std::string symbol_string(const si::activity&) { return "Bq"; }
 
-inline std::string name_string(const si::capacitance&) { return "farad"; }
-inline std::string symbol_string(const si::capacitance&) { return "F"; }
+inline std::string name_string(const reduce_unit<si::capacitance>::type&) { return "farad"; }
+inline std::string symbol_string(const reduce_unit<si::capacitance>::type&) { return "F"; }
 
-inline std::string name_string(const si::catalytic_activity&) { return "katal"; }
-inline std::string symbol_string(const si::catalytic_activity&) { return "kat"; }
+inline std::string name_string(const reduce_unit<si::catalytic_activity>::type&) { return "katal"; }
+inline std::string symbol_string(const reduce_unit<si::catalytic_activity>::type&) { return "kat"; }
 
-inline std::string name_string(const si::conductance&) { return "siemen"; }
-inline std::string symbol_string(const si::conductance&) { return "S"; }
+inline std::string name_string(const reduce_unit<si::conductance>::type&) { return "siemen"; }
+inline std::string symbol_string(const reduce_unit<si::conductance>::type&) { return "S"; }
 
 // gray and sievert are indistinguishable
 //inline std::string name_string(const si::dose_equivalent&) { return "sievert"; }
 //inline std::string symbol_string(const si::dose_equivalent&) { return "Sv"; }
 
-inline std::string name_string(const si::electric_charge&) { return "coulomb"; }
-inline std::string symbol_string(const si::electric_charge&) { return "C"; }
+inline std::string name_string(const reduce_unit<si::electric_charge>::type&) { return "coulomb"; }
+inline std::string symbol_string(const reduce_unit<si::electric_charge>::type&) { return "C"; }
 
-inline std::string name_string(const si::electric_potential&) { return "volt"; }
-inline std::string symbol_string(const si::electric_potential&) { return "V"; }
+inline std::string name_string(const reduce_unit<si::electric_potential>::type&) { return "volt"; }
+inline std::string symbol_string(const reduce_unit<si::electric_potential>::type&) { return "V"; }
 
-inline std::string name_string(const si::energy&) { return "joule"; }
-inline std::string symbol_string(const si::energy&) { return "J"; }
+inline std::string name_string(const reduce_unit<si::energy>::type&) { return "joule"; }
+inline std::string symbol_string(const reduce_unit<si::energy>::type&) { return "J"; }
 
-inline std::string name_string(const si::force&) { return "newton"; }
-inline std::string symbol_string(const si::force&) { return "N"; }
+inline std::string name_string(const reduce_unit<si::force>::type&) { return "newton"; }
+inline std::string symbol_string(const reduce_unit<si::force>::type&) { return "N"; }
 
-inline std::string name_string(const si::frequency&) { return "hertz"; }
-inline std::string symbol_string(const si::frequency&) { return "Hz"; }
+inline std::string name_string(const reduce_unit<si::frequency>::type&) { return "hertz"; }
+inline std::string symbol_string(const reduce_unit<si::frequency>::type&) { return "Hz"; }
 
-inline std::string name_string(const si::illuminance&) { return "lux"; }
-inline std::string symbol_string(const si::illuminance&) { return "lx"; }
+inline std::string name_string(const reduce_unit<si::illuminance>::type&) { return "lux"; }
+inline std::string symbol_string(const reduce_unit<si::illuminance>::type&) { return "lx"; }
 
-inline std::string name_string(const si::inductance&) { return "henry"; }
-inline std::string symbol_string(const si::inductance&) { return "H"; }
+inline std::string name_string(const reduce_unit<si::inductance>::type&) { return "henry"; }
+inline std::string symbol_string(const reduce_unit<si::inductance>::type&) { return "H"; }
 
-inline std::string name_string(const si::luminous_flux&) { return "lumen"; }
-inline std::string symbol_string(const si::luminous_flux&) { return "lm"; }
+inline std::string name_string(const reduce_unit<si::luminous_flux>::type&) { return "lumen"; }
+inline std::string symbol_string(const reduce_unit<si::luminous_flux>::type&) { return "lm"; }
 
-inline std::string name_string(const si::magnetic_flux&) { return "weber"; }
-inline std::string symbol_string(const si::magnetic_flux&) { return "Wb"; }
+inline std::string name_string(const reduce_unit<si::magnetic_flux>::type&) { return "weber"; }
+inline std::string symbol_string(const reduce_unit<si::magnetic_flux>::type&) { return "Wb"; }
 
-inline std::string name_string(const si::magnetic_flux_density&) { return "tesla"; }
-inline std::string symbol_string(const si::magnetic_flux_density&) { return "T"; }
+inline std::string name_string(const reduce_unit<si::magnetic_flux_density>::type&) { return "tesla"; }
+inline std::string symbol_string(const reduce_unit<si::magnetic_flux_density>::type&) { return "T"; }
 
-inline std::string name_string(const si::power&) { return "watt"; }
-inline std::string symbol_string(const si::power&) { return "W"; }
+inline std::string name_string(const reduce_unit<si::power>::type&) { return "watt"; }
+inline std::string symbol_string(const reduce_unit<si::power>::type&) { return "W"; }
 
-inline std::string name_string(const si::pressure&) { return "pascal"; }
-inline std::string symbol_string(const si::pressure&) { return "Pa"; }
+inline std::string name_string(const reduce_unit<si::pressure>::type&) { return "pascal"; }
+inline std::string symbol_string(const reduce_unit<si::pressure>::type&) { return "Pa"; }
 
-inline std::string name_string(const si::resistance&) { return "ohm"; }
-inline std::string symbol_string(const si::resistance&) { return "Ω"; }
+inline std::string name_string(const reduce_unit<si::resistance>::type&) { return "ohm"; }
+inline std::string symbol_string(const reduce_unit<si::resistance>::type&) { return "Ω"; }
 
 
 } // 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