Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-26 20:50:33


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

Log:
Fixed use of dim instead of heterogeneous_system_dim and added missing disambiguating overloads
Text files modified:
   sandbox/units/boost/units/io.hpp | 76 ++++++++++++++++++++++++++++++++++-----
   sandbox/units/libs/units/test/test_scaled_unit.cpp | 4 +-
   2 files changed, 68 insertions(+), 12 deletions(-)

Modified: sandbox/units/boost/units/io.hpp
==============================================================================
--- sandbox/units/boost/units/io.hpp (original)
+++ sandbox/units/boost/units/io.hpp 2008-05-26 20:50:33 EDT (Mon, 26 May 2008)
@@ -393,16 +393,44 @@
 }
 
 /// INTERNAL ONLY
+template<class Dimension,class Unit,class Scale>
+inline std::string
+symbol_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<Unit, static_rational<1> >,dimensionless_type>, Dimension, Scale> > >&)
+{
+ std::string str;
+
+ detail::scale_symbol_string_impl<mpl::size<Scale>::value>::template apply<
+ typename mpl::begin<Scale>::type>::value(str);
+
+ str += symbol_string(unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<Unit, static_rational<1> >, dimensionless_type>, Dimension, dimensionless_type> > >());
+
+ return(str);
+}
+
+/// INTERNAL ONLY
+template<class Dimension,class Unit>
+inline std::string
+symbol_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<Unit, static_rational<1> >,dimensionless_type>, Dimension, dimensionless_type> > >&)
+{
+ std::string str;
+
+ detail::symbol_string_impl<mpl::size<list<heterogeneous_system_dim<Unit, static_rational<1> >,dimensionless_type> >::value>::template apply<
+ typename mpl::begin<list<heterogeneous_system_dim<Unit, static_rational<1> >,dimensionless_type> >::type>::value(str);
+
+ return(str);
+}
+
+/// INTERNAL ONLY
 template<class Dimension,class Unit,class UnitScale, class Scale>
 inline std::string
-symbol_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type>, Dimension, Scale> > >&)
+symbol_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type>, Dimension, Scale> > >&)
 {
     return(symbol_string(
         unit<
             Dimension,
             heterogeneous_system<
                 heterogeneous_system_impl<
- list<dim<Unit, static_rational<1> >, dimensionless_type>,
+ list<heterogeneous_system_dim<Unit, static_rational<1> >, dimensionless_type>,
                     Dimension,
                     typename mpl::times<Scale, list<UnitScale, dimensionless_type> >::type
>
@@ -414,12 +442,12 @@
 // disambiguate
 template<class Dimension,class Unit,class UnitScale>
 inline std::string
-symbol_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type>, Dimension, dimensionless_type> > >&)
+symbol_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type>, Dimension, dimensionless_type> > >&)
 {
     std::string str;
     
- detail::symbol_string_impl<mpl::size<list<dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type> >::value>::template apply<
- typename mpl::begin<list<dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type> >::type>::value(str);
+ detail::symbol_string_impl<mpl::size<list<heterogeneous_system_dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type> >::value>::template apply<
+ typename mpl::begin<list<heterogeneous_system_dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type> >::type>::value(str);
 
     return(str);
 }
@@ -480,16 +508,44 @@
 }
 
 /// INTERNAL ONLY
+template<class Dimension,class Unit,class Scale>
+inline std::string
+name_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<Unit, static_rational<1> >,dimensionless_type>, Dimension, Scale> > >&)
+{
+ std::string str;
+
+ detail::scale_name_string_impl<mpl::size<Scale>::value>::template apply<
+ typename mpl::begin<Scale>::type>::value(str);
+
+ str += name_string(unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<Unit, static_rational<1> >, dimensionless_type>, Dimension, dimensionless_type> > >());
+
+ return(str);
+}
+
+/// INTERNAL ONLY
+template<class Dimension,class Unit>
+inline std::string
+name_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<Unit, static_rational<1> >,dimensionless_type>, Dimension, dimensionless_type> > >&)
+{
+ std::string str;
+
+ detail::name_string_impl<mpl::size<list<heterogeneous_system_dim<Unit, static_rational<1> >,dimensionless_type> >::value>::template apply<
+ typename mpl::begin<list<heterogeneous_system_dim<Unit, static_rational<1> >,dimensionless_type> >::type>::value(str);
+
+ return(str);
+}
+
+/// INTERNAL ONLY
 template<class Dimension,class Unit,class UnitScale, class Scale>
 inline std::string
-name_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type>, Dimension, Scale> > >&)
+name_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type>, Dimension, Scale> > >&)
 {
     return(name_string(
         unit<
             Dimension,
             heterogeneous_system<
                 heterogeneous_system_impl<
- list<dim<Unit, static_rational<1> >, dimensionless_type>,
+ list<heterogeneous_system_dim<Unit, static_rational<1> >, dimensionless_type>,
                     Dimension,
                     typename mpl::times<Scale, list<UnitScale, dimensionless_type> >::type
>
@@ -501,12 +557,12 @@
 // disambiguate
 template<class Dimension,class Unit,class UnitScale>
 inline std::string
-name_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type>, Dimension, dimensionless_type> > >&)
+name_string(const unit<Dimension, heterogeneous_system<heterogeneous_system_impl<list<heterogeneous_system_dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type>, Dimension, dimensionless_type> > >&)
 {
     std::string str;
     
- detail::name_string_impl<mpl::size<list<dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type> >::value>::template apply<
- typename mpl::begin<list<dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type> >::type>::value(str);
+ detail::name_string_impl<mpl::size<list<heterogeneous_system_dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type> >::value>::template apply<
+ typename mpl::begin<list<heterogeneous_system_dim<scaled_base_unit<Unit, UnitScale>, static_rational<1> >, dimensionless_type> >::type>::value(str);
     return(str);
 }
 

Modified: sandbox/units/libs/units/test/test_scaled_unit.cpp
==============================================================================
--- sandbox/units/libs/units/test/test_scaled_unit.cpp (original)
+++ sandbox/units/libs/units/test/test_scaled_unit.cpp 2008-05-26 20:50:33 EDT (Mon, 26 May 2008)
@@ -66,11 +66,11 @@
 BOOST_AUTO_TEST_CASE(test_output) {
     std::stringstream stream;
     stream << si::nano * 12.5 * si::seconds;
- BOOST_CHECK_EQUAL(stream.str(), "12.5 10^-9 s");
+ BOOST_CHECK_EQUAL(stream.str(), "12.5 ns");
 }
 
 BOOST_AUTO_TEST_CASE(test_output_name) {
     std::stringstream stream;
     stream << bu::name_format << si::nano * 12.5 * si::seconds;
- BOOST_CHECK_EQUAL(stream.str(), "12.5 10^-9 second");
+ BOOST_CHECK_EQUAL(stream.str(), "12.5 nanosecond");
 }


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