flush_emit
should set badbit
if the emit
call failsSection: 31.7.6.5 [ostream.manip] Status: C++23 Submitter: Tim Song Opened: 2021-06-19 Last modified: 2023-11-22
Priority: Not Prioritized
View all other issues in [ostream.manip].
View all issues with C++23 status.
Discussion:
basic_osyncstream::emit
is specified to set badbit
if it fails
(31.11.3.3 [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.
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.
[2021-06-23; Reflector poll]
Set status to Tentatively Ready after six votes in favour during reflector poll.
[2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N4885.
Modify 31.7.6.5 [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, ifos.rdbuf()
is abasic_syncbuf<charT, traits, Allocator>*
, calledbuf
for the purpose of exposition, behaves as an unformatted output function (31.7.6.4 [ostream.unformatted]) ofos
. After constructing asentry
object, callsbuf->emit()
. If that call returnsfalse
, callsos.setstate(ios_base::badbit)
.