Title
flush_emit should set badbit if the emit call fails
Status
c++23
Section
[ostream.manip]
Submitter
Tim Song

Created on 2021-06-19.00:00:00 last changed 12 months ago

Messages

Date: 2021-10-14.09:56:08

Proposed resolution:

This wording is relative to N4885.

  1. Modify [ostream.manip] as indicated:

    template<class charT, class traits>
      basic_ostream<charT, traits>& flush_emit(basic_ostream<charT, traits>& os);
    

    -12- Effects: Calls os.flush(). Then, if os.rdbuf() is a basic_syncbuf<charT, traits, Allocator>*, called buf for the purpose of exposition, behaves as an unformatted output function ([ostream.unformatted]) of os. After constructing a sentry object, calls buf->emit(). If that call returns false, calls os.setstate(ios_base::badbit).

Date: 2021-10-14.00:00:00

[ 2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP. ]

Date: 2021-06-15.00:00:00

[ 2021-06-23; Reflector poll ]

Set status to Tentatively Ready after six votes in favour during reflector poll.

Date: 2021-06-19.00:00:00

basic_osyncstream::emit is specified to set badbit if it fails ([syncstream.osyncstream.members] p1), but the emit part of the flush_emit manipulator isn't, even though the flush part does set badbit if it fails.

More generally, given an osyncstream s, s << flush_emit; should probably have the same behavior as s.flush(); s.emit().

The reference implementation linked in P0753R2 does set badbit on failure, so at least this part appears to be an oversight. As discussed in LWG 3570, basic_osyncstream::emit should probably be an unformatted output function, so the emit part of flush_emit should do so too.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2021-10-14 09:56:08adminsetmessages: + msg12133
2021-10-14 09:56:08adminsetstatus: voting -> wp
2021-09-29 12:57:28adminsetstatus: ready -> voting
2021-06-23 14:16:45adminsetmessages: + msg11966
2021-06-23 14:16:45adminsetstatus: new -> ready
2021-06-19 15:11:17adminsetmessages: + msg11942
2021-06-19 00:00:00admincreate