News for hackers. Stuff that matters.
Re:F-strings for C++26 proposal [pdf] by HeliumHydride on Sunday February 02, 2025 @06:47PM (#42913126)
C++ also has std::format, which was introduced in C++20. This is just sugar on top of it, except it also returns a container type so that printing functions can have overloads that format into a file or stream directly from an f-string, instead of going through the overhead of a temporary string.
Re:F-strings for C++26 proposal [pdf] by rerdavies on Monday February 03, 2025 @03:37AM (#42916171)
I'm wonder what this mysterious application is that is doing heavy formatting of strings but can't afford the overhead of a temporary string, and therefore requires horrifying and inscrutable and dangerous language extensions.
Re:F-strings for C++26 proposal [pdf] by chlorion on Monday February 03, 2025 @04:02AM (#42916316)
Being able to use string formatting without a heap is pretty cool.

Rusts string formatting machinery does not require any heap allocations at all, you can for example impl fmt::Write for a struct that writes directly to a serial console byte-by-byte with no allocations, and then you have access to all of rusts string formatting features available to print over a serial console!

I'm not sure about the horrifying and dangerous extensions part though, I'm not really a C++ expert so I don't know if there's a better way to do what they want to do.

Re:F-strings for C++26 proposal [pdf] by badmintonbaseba on Monday February 03, 2025 @04:57AM (#42916651)
freestanding maybe? Embedded apps often don't shy away from using something like printf, yet they don't like unnecessary allocations.
Re:F-strings for C++26 proposal [pdf] by gpderetta on Wednesday February 05, 2025 @10:33AM (#42949936)
For example, an high performance logger can ship the tuple object to a background thread for actual formatting and I/O, after converting the capture to by-value.

Formatting on the foreground thread would be a non-starter.