Opened 10 years ago
Closed 10 years ago
#6871 closed Bugs (wontfix)
chrono_io.hpp: operator<<(ostream& os, ...) modifies the state of os
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.52.0 | Component: | chrono |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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.
Change History (6)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Status: | new → assigned |
---|
comment:3 by , 10 years ago
Milestone: | To Be Determined → Boost 1.52.0 |
---|---|
Version: | Boost Development Trunk → Boost 1.47.0 |
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:5 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:6 by , 10 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
I have no fix for io version 1. You should move to version 2.
I'm reworking the chrono io for version v2 which uses ios_base states instead of locale facets. Could you check if the version 2 solves the issue?