Boost logo

Boost :

From: (noreply_at_[hidden])
Date: 2004-07-12 10:03:04

Bugs item #989487, was opened at 2004-07-12 22:03
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:

Category: date_time
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Vyacheslav E. Andrejev (vandrejev)
Assigned to: Jeff Garland (az_sw_dude)
Summary: wrong usage of ios_base::narrow

Initial Comment:
revision 1.18, lines 207, 214

std::stringstream has char_type typedef evidently equal
to char, not wchar_t, so in std::stringstream::narrow
function the first argument has type char and in the call

ss << ss.narrow(*beg++, 'X');

*beg will be converted from wchar_t to char before call
to narrow will be made.

I suggest the following patch:

diff -c -r1.18 date_parsing.hpp
*** 207,214 ****
        std::stringstream ss("");
        while(beg != end) {
! ss << ss.narrow(*beg++, 'X'); // 'X' will cause
exception to be thrown
        return parse_date<date_type>(ss.str());
--- 207,215 ----
        std::stringstream ss("");
+ std::locale loc;
        while(beg != end) {
! ss << std::use_facet<std::ctype<wchar_t> >
(loc).narrow(*beg++, 'X');
        return parse_date<date_type>(ss.str());


You can respond by visiting:

This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit
Boost-bugs mailing list

Boost list run by bdawes at, gregod at, cpdaniel at, john at