r/cpp • u/alberto-m-dev • Jun 26 '26
Improvements to std::format in C++26
https://mariusbancila.ro/blog/2026/06/19/improvements-to-stdformat-in-c26/
91
Upvotes
r/cpp • u/alberto-m-dev • Jun 26 '26
38
u/fdwr fdwr@github ๐ Jun 26 '26
Wait, is that really true, that the uppercase also capitalizes the 'x'? ๐ The usual norm for hex numbers is 0x12AB (hex constants, stack traces, hex editors...), not 0X12AB or 0x12ab. So if the article is accurate, then none of the pointer defaults fit the most common case, meaning I'll continue to use
0x{:08X}.18
u/pclouds Jun 26 '26
I thought when std::format became part of the standard, error messages would improve. At least with gcc, format error is still a wall of text. Has this been improved (or in some sort of backlog)?
7
u/Nice_Lengthiness_568 Jun 26 '26
Nice.
Would love to have something fmtlib's colors for format and print too.
2
u/rdtsc Jun 26 '26
I don't understand. Does this do UTF-16 -> UTF-8 -> system codepage? Or does
std::format("{}", path)result in (unexpected) UTF-8 in a char-based (aka system codepage) string?-11
u/R3DKn16h7 Jun 26 '26
I don't like the API change to make the format string a constant expression. It should have been like that from the beginning or should have gotten another name...