|
From: Matthias S. <mat...@us...> - 2007-03-30 23:50:22
|
Update of /cvsroot/boost-sandbox/boost-sandbox/libs/units/example In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16949/example Modified Files: unit_example_19.cpp unit_example_20.cpp unit_example_4.cpp Log Message: minor fixes Index: unit_example_20.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_20.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- unit_example_20.cpp 29 Mar 2007 17:10:55 -0000 1.2 +++ unit_example_20.cpp 30 Mar 2007 23:50:10 -0000 1.3 @@ -32,13 +32,12 @@ @endverbatim **/ -#define MCS_USE_BOOST_REGEX_DEMANGLING - #include <algorithm> #include <iomanip> #include <iostream> #include <sstream> +#include <boost/units/absolute.hpp> #include <boost/units/io.hpp> #include <boost/units/unit.hpp> #include <boost/units/quantity.hpp> @@ -46,7 +45,7 @@ #include <boost/units/detail/utility.hpp> using namespace boost::units; - +/* template<class Y = double> class absolute { @@ -128,7 +127,7 @@ return os; } - +*/ namespace boost { namespace units { @@ -182,15 +181,15 @@ }; template<class Y> -class conversion_helper< quantity<unit<temperature_type,fahrenheit::system>,relative<Y> >, - quantity<unit<temperature_type,SI::system>,relative<Y> > > +class conversion_helper< quantity<unit<temperature_type,fahrenheit::system>,Y>, + quantity<unit<temperature_type,SI::system>,Y> > { public: typedef unit<temperature_type,fahrenheit::system> unit1_type; typedef unit<temperature_type,SI::system> unit2_type; - typedef quantity<unit1_type,relative<Y> > from_quantity_type; - typedef quantity<unit2_type,relative<Y> > to_quantity_type; + typedef quantity<unit1_type,Y> from_quantity_type; + typedef quantity<unit2_type,Y> to_quantity_type; static to_quantity_type @@ -198,7 +197,7 @@ { const typename from_quantity_type::value_type& in(source.value()); - return to_quantity_type::from_value(in.value()*(5.0/9.0)); + return to_quantity_type::from_value(in*(5.0/9.0)); } }; @@ -211,17 +210,17 @@ std::stringstream sstream1, sstream2; quantity<fahrenheit::temperature,absolute<> > T1p(absolute<>(32)*fahrenheit::degrees); - quantity<fahrenheit::temperature,relative<> > T1v(relative<>(32)*fahrenheit::degrees); + quantity<fahrenheit::temperature> T1v(32*fahrenheit::degrees); quantity<SI::temperature,absolute<> > T2p(T1p); quantity<SI::temperature,absolute<> > T3p = T1p; - quantity<SI::temperature,relative<> > T2v(T1v); - quantity<SI::temperature,relative<> > T3v = T1v; + quantity<SI::temperature> T2v(T1v); + quantity<SI::temperature> T3v = T1v; typedef conversion_helper<quantity<fahrenheit::temperature,absolute<> >, quantity<SI::temperature,absolute<> > > absolute_conv_type; - typedef conversion_helper<quantity<fahrenheit::temperature,relative<> >, - quantity<SI::temperature,relative<> > > relative_conv_type; + typedef conversion_helper<quantity<fahrenheit::temperature,double>, + quantity<SI::temperature,double> > relative_conv_type; sstream1 << T1p << std::endl << absolute_conv_type::convert(T1p) << std::endl @@ -233,14 +232,14 @@ << T3v << std::endl << std::endl; - sstream2 << "{ 32 } F" << std::endl - << "{ 273.16 } K" << std::endl - << "{ 273.16 } K" << std::endl - << "{ 273.16 } K" << std::endl - << "[ 32 ] F" << std::endl - << "[ 17.7778 ] K" << std::endl - << "[ 17.7778 ] K" << std::endl - << "[ 17.7778 ] K" << std::endl + sstream2 << "32 absolute F" << std::endl + << "273.16 absolute K" << std::endl + << "273.16 absolute K" << std::endl + << "273.16 absolute K" << std::endl + << "32 F" << std::endl + << "17.7778 K" << std::endl + << "17.7778 K" << std::endl + << "17.7778 K" << std::endl << std::endl; std::string str1(sstream1.str()); Index: unit_example_4.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_4.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- unit_example_4.cpp 29 Mar 2007 19:39:28 -0000 1.2 +++ unit_example_4.cpp 30 Mar 2007 23:50:10 -0000 1.3 @@ -141,13 +141,12 @@ #include <algorithm> #include <sstream> +#include <boost/units/measurement.hpp> #include <boost/units/io.hpp> #include <boost/units/systems/si.hpp> #include <boost/units/systems/trig.hpp> #include <boost/units/systems/si/codata/physico-chemical_constants.hpp> -#include "measurement.hpp" - namespace boost { namespace units { @@ -409,8 +408,7 @@ << std::endl; /// check quantities using user-defined type encapsulating error propagation - using namespace mcs; - + //[unit_example_4_snippet_8 quantity<length,measurement<double> > u(measurement<double>(1.0,0.0)*meters), w(measurement<double>(4.52,0.02)*meters), @@ -494,7 +492,7 @@ sstream2 << "T = 310 K" << std::endl; sstream2 << "n = " << 2.05835e-17 << " mol" << std::endl; #if BOOST_UNITS_HAS_TYPEOF - sstream2 << "R = 8.31447 m^2 kg s^(-2) K^(-1) mol^(-1)" << std::endl; + sstream2 << "R = 8.31447(+/-1.5e-05) m^2 kg s^(-2) K^(-1) mol^(-1)" << std::endl; #else sstream2 << "no typeof" << std::endl; #endif // BOOST_UNITS_HAS_TYPEOF Index: unit_example_19.cpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/libs/units/example/unit_example_19.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- unit_example_19.cpp 16 Mar 2007 18:29:53 -0000 1.1.1.1 +++ unit_example_19.cpp 30 Mar 2007 23:50:10 -0000 1.2 @@ -184,7 +184,7 @@ int main() { using namespace boost::units::SI::constants::CODATA; - + std::cout << "CODATA physical constants:" << std::endl; std::cout << std::endl << "Universal constants: " << std::endl << std::endl |