C++ Logo

sg16

Advanced search

Re: [isocpp-lib-ext] Formatters converting sequences of char to sequences of wchar_t

From: Victor Zverovich <victor.zverovich_at_[hidden]>
Date: Wed, 7 Jun 2023 11:47:55 -0700
> You want to keep allowing this conversion?

I see no reason to disable it because it's not string-like but we should
probably disallow s and ?s specifiers if code unit types don't match. One
more question to SG16 I guess.

- Victor



On Wed, Jun 7, 2023 at 11:27 AM Mark de Wever <koraq_at_[hidden]> wrote:

> On Wed, Jun 07, 2023 at 11:09:21AM -0700, Victor Zverovich via Lib-Ext
> wrote:
> > OK, I finally found time to look into this in detail and now convinced
> that
> > the correct solution is to update
> > http://eel.is/c++draft/format#formatter.spec disabling all formatters
> > listed there that may mix code unit types except for formatter<char,
> > wchar_t>. Previously they were disabled implicitly but C++23
> inadvertently
> > enabled them. For example, we should disable
> >
> > template<class traits, class Allocator>
> > struct formatter<basic_string<charT, traits, Allocator>, Char>;
> >
> > when Char is different from charT.
>
> This indeed matches my conclusion for the minimal fix.
>
> Only making that change does not prevent
>
> format(L"{}", vector{'H', 'i'}); // gives ['H', 'i']
>
> since that uses
>
> formatter<char, wchar_t>
>
> You want to keep allowing this conversion?
>
> Cheers,
> Mark
>

Received on 2023-06-07 18:48:07