[ http://issues.apache.org/jira/browse/STDCXX-205?page=comments#action_12420401 ]
Martin Sebor commented on STDCXX-205: ------------------------------------- As pointed in the post linked above, lib.string.io, p5, requires that width(0) be called after the characters have been [presumably successfully] inserted into the stream's buffer: -5- Effects: Begins by constructing a sentry object k as if k were constructed by typename basic_ostream<charT, traits>::sentry k (os ). If bool(k) is true, determines padding as described in 22.2.2.2.2, then inserts the resulting sequence of characters seq as if by calling os.rdbuf()->sputn(seq , n), where n is the larger of os.width() and str.size(); then calls os .width(0). If the call to sputn fails, calls os .setstate(ios_base::failbit). > std::operator<<(ostream, string) calls width(0) regardless of sentry > -------------------------------------------------------------------- > > Key: STDCXX-205 > URL: http://issues.apache.org/jira/browse/STDCXX-205 > Project: C++ Standard Library > Type: Bug > Components: 21. Strings > Versions: 4.1.3 > Environment: all > Reporter: Anton Pevtsov > Assignee: Martin Sebor > Priority: Minor > > The following test fails: > #include <iostream> > #include <sstream> > #include <string> > #include <cassert> > int main(int argc, char* argv[]) > { > std::string str ("abcdefghijk"); > std::ostringstream os; > const std::streamsize width = 2; > os.width (width); > os.clear (std::ios_base::failbit); > os << str; > assert (os.width () == width); > return 0; > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
