The C++26 standard features a series of improvements to the format library. In this article, we will look at the most important of them.
Printing an empty line
Prior to C++26, printing an empty line had to be done like this:
std::print("
");
In C++26, std::println has an overload without any parameters that prints a new line to the console.
std::print();
Formatting pointers
Formatting pointer types was not available directly, it required a hack: reinterpreting the pointer type as an integer type in order to print it.
int i = 0; const void* p = &i; std::println("{:#018x}", reinterpret_cast<uintptr_t>(p));
... continue reading