3 ms·
I don't like a lot of things in C++, but one thing worth praising in particular is std::format std::format specifically only works for constant† format strings
by tialaramex 4y ago
I don't like a lot of things in C++, but one thing worth praising in particular is std::format
std::format specifically only works for constant† format strings. Not because they can't make it work with a dynamic format, std::vformat is exactly that, but most of the time you don't want and shouldn't use a dynamic format and the choice to refuse dynamic formats in std::format means fewer people are going to end up shooting themselves in the foot.
Because it requires constant formats, std::format also gets to guarantee compile time errors. Too many or not enough arguments? Program won't build. Wrong types? Program won't build. This shifts some nasty errors hard left.
† Not necessarily a literal, any constant expression, so it just needs to have some concrete value when it's compiled.
- planede 4y agoNice, I didn't know about https://wg21.link/P2216 https://wg21.link/P2216 .