|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53577 - in trunk: boost/units libs/units/test
From: steven_at_[hidden]
Date: 2009-06-02 17:02:57
Author: steven_watanabe
Date: 2009-06-02 17:02:56 EDT (Tue, 02 Jun 2009)
New Revision: 53577
URL: http://svn.boost.org/trac/boost/changeset/53577
Log:
Allow absolute to be printed to std::wostream. Fixes #3089
Text files modified:
trunk/boost/units/absolute.hpp | 7 +++----
trunk/libs/units/test/test_output.cpp | 7 +++++++
2 files changed, 10 insertions(+), 4 deletions(-)
Modified: trunk/boost/units/absolute.hpp
==============================================================================
--- trunk/boost/units/absolute.hpp (original)
+++ trunk/boost/units/absolute.hpp 2009-06-02 17:02:56 EDT (Tue, 02 Jun 2009)
@@ -11,8 +11,7 @@
#ifndef BOOST_UNITS_ABSOLUTE_HPP
#define BOOST_UNITS_ABSOLUTE_HPP
-// necessary because the expression os << "absolute " is not dependent.
-#include <ostream>
+#include <iosfwd>
#include <boost/units/detail/absolute_impl.hpp>
@@ -90,8 +89,8 @@
}
/// Print an absolute unit
-template<class Y>
-std::ostream& operator<<(std::ostream& os,const absolute<Y>& aval)
+template<class Char, class Traits, class Y>
+std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os,const absolute<Y>& aval)
{
os << "absolute " << aval.value();
Modified: trunk/libs/units/test/test_output.cpp
==============================================================================
--- trunk/libs/units/test/test_output.cpp (original)
+++ trunk/libs/units/test/test_output.cpp 2009-06-02 17:02:56 EDT (Tue, 02 Jun 2009)
@@ -25,6 +25,7 @@
#include <boost/units/make_scaled_unit.hpp>
#include <boost/units/base_unit.hpp>
#include <boost/units/make_system.hpp>
+#include <boost/units/absolute.hpp>
#include <boost/units/physical_dimensions/length.hpp>
#include <boost/units/physical_dimensions/time.hpp>
#include <boost/units/physical_dimensions/velocity.hpp>
@@ -122,6 +123,7 @@
BOOST_UNITS_TEST_OUTPUT(custom2(), "c2");
BOOST_UNITS_TEST_OUTPUT(scaled_custom1(), "kc1");
BOOST_UNITS_TEST_OUTPUT(scaled_custom2(), "kc2");
+ BOOST_UNITS_TEST_OUTPUT(boost::units::absolute<meter_base_unit::unit_type>(), "absolute m");
#undef FORMATTERS
}
@@ -142,6 +144,7 @@
BOOST_UNITS_TEST_OUTPUT(custom2(), "m s^-2");
BOOST_UNITS_TEST_OUTPUT(scaled_custom1(), "k(m^3)");
BOOST_UNITS_TEST_OUTPUT(scaled_custom2(), "k(m s^-2)");
+ BOOST_UNITS_TEST_OUTPUT(boost::units::absolute<meter_base_unit::unit_type>(), "absolute m");
#undef FORMATTERS
}
@@ -161,6 +164,7 @@
BOOST_UNITS_TEST_OUTPUT(custom2(), "custom2");
BOOST_UNITS_TEST_OUTPUT(scaled_custom1(), "kilocustom1");
BOOST_UNITS_TEST_OUTPUT(scaled_custom2(), "kilocustom2");
+ BOOST_UNITS_TEST_OUTPUT(boost::units::absolute<meter_base_unit::unit_type>(), "absolute meter");
#undef FORMATTERS
}
@@ -181,6 +185,7 @@
BOOST_UNITS_TEST_OUTPUT(1.5*custom2(), "1.5 c2");
BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom1(), "1.5 kc1");
BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom2(), "1.5 kc2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*boost::units::absolute<meter_base_unit::unit_type>(), "1.5 absolute m");
#undef FORMATTERS
}
@@ -201,6 +206,7 @@
BOOST_UNITS_TEST_OUTPUT(1.5*custom2(), "1.5 m s^-2");
BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom1(), "1.5 k(m^3)");
BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom2(), "1.5 k(m s^-2)");
+ BOOST_UNITS_TEST_OUTPUT(1.5*boost::units::absolute<meter_base_unit::unit_type>(), "1.5 absolute m");
#undef FORMATTERS
}
@@ -220,6 +226,7 @@
BOOST_UNITS_TEST_OUTPUT(1.5*custom2(), "1.5 custom2");
BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom1(), "1.5 kilocustom1");
BOOST_UNITS_TEST_OUTPUT(1.5*scaled_custom2(), "1.5 kilocustom2");
+ BOOST_UNITS_TEST_OUTPUT(1.5*boost::units::absolute<meter_base_unit::unit_type>(), "1.5 absolute meter");
#undef FORMATTERS
}
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