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

### 581. `flush()` not unformatted function

Section: 31.7.6.4 [ostream.unformatted] Status: CD1 Submitter: Martin Sebor Opened: 2006-06-14 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [ostream.unformatted].

View all issues with CD1 status.

Discussion:

The resolution of issue 60 changed `basic_ostream::flush()` so as not to require it to behave as an unformatted output function. That has at least two in my opinion problematic consequences:

First, `flush()` now calls `rdbuf()->pubsync()` unconditionally, without regard to the state of the stream. I can't think of any reason why `flush()` should behave differently from the vast majority of stream functions in this respect.

Second, `flush()` is not required to catch exceptions from `pubsync()` or set `badbit` in response to such events. That doesn't seem right either, as most other stream functions do so.

Proposed resolution:

I propose to revert the resolution of issue 60 with respect to `flush()`. Specifically, I propose to change 27.6.2.6, p7 as follows:

Effects: Behaves as an unformatted output function (as described in 27.6.2.6, paragraph 1). If `rdbuf()` is not a null pointer, constructs a sentry object. If this object returns `true` when converted to a value of type bool the function calls `rdbuf()->pubsync()`. If that function returns -1 calls `setstate(badbit)` (which may throw `ios_base::failure` (27.4.4.3)). Otherwise, if the sentry object returns `false`, does nothing.Does not behave as an unformatted output function (as described in 27.6.2.6, paragraph 1).

[ Kona (2007): Proposed Disposition: Ready ]