Subject: [Boost-bugs] [Boost C++ Libraries] #6871: chrono_io.hpp: operator<<(ostream& os, ...) modifies the state of os
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-06 15:09:32
#6871: chrono_io.hpp: operator<<(ostream& os, ...) modifies the state of os
-------------------------------------+--------------------------------------
Reporter: vkh@⦠| Owner: viboes
Type: Bugs | Status: new
Milestone: To Be Determined | Component: chrono
Version: Boost Development Trunk | Severity: Problem
Keywords: |
-------------------------------------+--------------------------------------
The code
std::locale loc = os.getloc();
if (!std::has_facet<Facet>(loc))
os.imbue(std::locale(loc, new Facet));
causes the state of os to be changed. It requires the CLIENT code to do
own locale saving, like in
{
boost::io::ios_locale_saver loc(std::cout);
std::cout << boost::chrono::system_clock::now() << std::endl;
}
Compare this to stream io code in boost/date_time (e.g.,
gregorian_io.hpp), that begins with a (correct)
boost::io::ios_flags_saver iflags(os);
Please fix chrono to behave similarly.
Discovered with 1.47.0 in chrono/chrono_io.hpp, but also exists on the
trunk in chrono/io_v1/chrono_io.hpp.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6871> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC