This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

2121. app for string streams

Section: 31.8.5.2 [stringstream.cons] Status: NAD Submitter: Nicolai Josuttis Opened: 2012-01-15 Last modified: 2018-06-07

Priority: 3

View all issues with NAD status.

Discussion:

This issue was raised while discussing issue 1448.

Note the following program:

string s("s1: 123456789");
ostringstream s1(s, ios_base::out|ios_base::app);
s1 << "hello";
cout << s1.str() << endl;

With g++4.x it prints:

s1: 123456789hello

With VisualC++10 it prints:

hello23456789

From my intuitive understanding the flag "app" should result in the output of g++4.x. I also would read that from [ios::openmode] claiming:

app   seek to end before each write

However in issue 1448 P.J.Plauger comments:

I think we should say nothing special about app at construction time (thus leaving the write pointer at the beginning of the buffer). Leave implementers wiggle room to ensure subsequent append writes as they see fit, but don't change existing rules for initial seek position.

Note that the flag ate on both platforms appends "hello" to s.

[2018-06; Rapperswil Wednesday evening]

MC: shouldn't this be Open?
BO: I think we changed it to do the same thing as gcc
JM: NAD - gcc is right
ACTION close as NAD, noting that gcc is right

Proposed resolution: