Talk:cpp/utility/format/formatter
Reordering of arguments in output?
The referred python format allows re-ordering of the arguments in the output string. The examples on this page does not mention this feature at all. Does C++20 std::format() allows reordering or not? --2003:E3:B71E:EF00:FD3E:72FF:AAAE:2B48 02:29, 1 June 2022 (PDT)
- It does, see arg-id in the format string specification in format() et al --Ybab321 (talk) 02:54, 1 June 2022 (PDT)
constexpr required for formatter<T, Char>::parse()?
While trying to implement a formatter, I noticed that both MSVC and GCC require making formatter::parse() constexpr (when used within std::format); otherwise the code doesn't compile (code on Coliru). MSVC STL (example) and GCC libc++ (example) also make their formatter::parse()s constexpr. So I think there is some sort of requirement about this; but I can't find evidence, and I don't really know much about this. Studyingegret (talk) 04:53, 8 November 2023 (PST)
- I don't believe constexpr parse is a requirement of a formatter. The issue is in the above code is that std::format expects a constant expression (via the consteval of std::format_string's ctor) of the parse of the given format string. If you instead use std::vformat, then the code works out. Probably worth adding a note on BasicFormatter --Ybab321 (talk) 07:03, 8 November 2023 (PST)
About splitting into 2 examples
I added my example and made the two examples separate. I think the style difference from other pages doesn't matter much, but feel free to revert my edit. I have left an unsplit revision in the page's edit history. Studyingegret (talk) 08:07, 8 November 2023 (PST)