This has been pushed now - thanks for the patch
On Thu, 20 Nov 2025 at 18:29, Jonathan Wakely <[email protected]> wrote:
>
> On Sat, 15 Nov 2025 at 19:48, Jonathan Wakely <[email protected]> wrote:
> >
> > On Sat, 15 Nov 2025 at 16:09, Yuao Ma <[email protected]> wrote:
> > >
> > > On Thu, Nov 13, 2025 at 11:40 PM Jonathan Wakely <[email protected]>
> > > wrote:
> > > > > And I'm a bit confused here. Why does adding `_Tp = _CharT` prevent
> > > > > the overload from appearing for wstream? I'm not sure what I'm
> > > > > missing.
> > > >
> > > > Oops, my suggestion was missing this line before the #endif
> > > >
> > > > ignore(streamsize __n, char __delim)
> > > >
> > > > i.e. the __delim should be char, not a deduced _Tp type.
> > > >
> > > > And so the __enable_if constraint is checking __are_same<_CharT, char>
> > > > which is not the same as your original, which was checking that
> > > > decltype(__delim) is char.
> > > >
> > > > The difference is that my suggestion would only enable the function
> > > > for std::basic_istream<char, Tr> and not std::basic_istream<wchar_t,
> > > > Tr>.
> > > >
> > >
> > > Thank you for explaining! Just to clarify:
> > > When we use char as the parameter type directly, we cannot infer the
> > > template argument from the user's input, so it will always default to
> > > the default template argument. And we still need an extra _Tp because
> > > SFINAE only works in the immediate context?
> >
> > You can't SFINAE at all without making it a function template, because
> > there's no SFINAE on normal functions.
> > So the point was to make it a function template with a template
> > parameter that can't be deduced, but defaults to _CharT. Then you can
> > do SFINAE constraints with enable_if on the template parameter _Tp.
> >
> > >
> > > > But please just make it a C++26 change anyway, and then we can just
> > > > use requires same_as<_CharT, char> which is exactly the constraint
> > > > proposed in P3223R2.
> > > >
> > >
> > > Done.
> > > The ambiguous test part has been removed. Do you think we need a
> > > compile failure test for this?
> >
> > No, I don't think so.
> >
> > Thanks for the new patch, I'll check it on Monday.
>
>
> This fix is needed for an existing test:
>
> --- a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/93672.cc
> +++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/93672.cc
> @@ -20,9 +20,9 @@ test_pr93672() // std::basic_istream::ignore hangs
> if delim MSB is set
> VERIFY( in.gcount() == 3 );
> VERIFY( ! in.eof() );
>
> - // This only works if char is unsigned.
> + // Prior to C++26 (P3223R2), this only works if char is unsigned.
> in.ignore(100, '\xfe');
> - if (std::numeric_limits<char>::is_signed)
> + if (std::numeric_limits<char>::is_signed && __cplusplus <= 202302)
> {
> // When char is signed, '\xfe' != traits_type::to_int_type('\xfe')
> // so the delimiter does not match the character in the input sequence,