std::char_traits<char>::eof
depends on non-freestanding EOF
Section: 27.2.4.2 [char.traits.specializations.char] Status: New Submitter: Jiang An Opened: 2024-04-03 Last modified: 2024-05-08
Priority: 2
View all other issues in [char.traits.specializations.char].
View all issues with New status.
Discussion:
Currently EOF
is not yet freestanding, because it's only specified to be provided in
<stdio.h>
in C, or together with <cstdio>
in C++.
std::char_traits<char>::eof
(required to be freestanding since C++26 by
P2338R4) is required to return the value of EOF
. It's unclear what is
expected to be done in a freestanding implementation.
Related to LLVM issue #85158.
[2024-05-08; Reflector poll]
Set priority to 2 after reflector poll.
"The eof
, not_eof
, to_int_type
and to_char_type
members of char_traits
are only needed by iostreams, so I see no reason for them to be freestanding.
In libstdc++ eof
and not_eof
depend on hosted, so are not freestanding.
Now that we can have partially freestanding classes in the library,
that seems like the right solution here."
"int_type
/char_type
/eof
is kind of poor-man (or C)'s
optional<char_type>
. Inclined to support it in freestanding
on that basis, even if the only standard component that uses it is iostreams."
"No implementer is confused about the value of eof()
/EOF
.
Having the value specified in the non-freestanding part of the standard
should be good enough."
"Prefer to make EOF freestanding, but don't feel strongly about it.
The important thing is keeping string_view
working."
Proposed resolution: