Hi Volker, > From my understanding, the idea behind the std::format framework would be > to have a “cardinality" type for which we can implement a special formatter, > allowing “whatever” to be in the format specification.
True, but the custom formatter specialization is called when the argument id is already parsed. In your example: std::format("{0:Cardinality}", Cardinality{42}); the std implementation parses the "{0:" part, extracting the argument id == 0, and then passes the rest of the string to the std::formatter<Cardinality> specialization. IIUC, Thiago suggested to use 'n' instead of the argument id. ------------------------------ Ivan Solovev Senior Software Engineer The Qt Company GmbH Erich-Thilo-Str. 10 12489 Berlin, Germany ivan.solo...@qt.io www.qt.io Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B ________________________________________ From: Development <development-boun...@qt-project.org> on behalf of Volker Hilsheimer via Development <development@qt-project.org> Sent: Thursday, October 24, 2024 9:43 AM To: Macieira, Thiago; development@qt-project.org Cc: albert astals cid; Volker Krause Subject: Re: [Development] format-like tr() > On 23 Oct 2024, at 22:55, Thiago Macieira <thiago.macie...@intel.com> wrote: >>> a) keep the "n" and make it mandatory, as in {n} >> >> If we use std::format, then we cannot do it, because it does the >> argument index parsing on its own, and delegates to a custom formatter >> specialization after that. And argument index can only be a non-negative >> integer value. > > Ok, so if we use their parser, the number must be {0} or the only, right? How > do we communicate to translators and tooling that this a plural form? >From my understanding, the idea behind the std::format framework would be to >have a “cardinality" type for which we can implement a special formatter, >allowing “whatever” to be in the format specification. https://godbolt.org/z/j6avb6afr Still supporting all the standard format specifications for integers is then an exercise I didn’t try. > Should we bring this to SG16 and ask for their long-term idea (C++26 or 29)? Always good to remind the committee that user interfaces are a thing ;) Volker -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development