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.

Reply via email to