top | item 42913084

(no title)

puffybuf | 1 year ago

I'm pretty sure boost::format can do this, though not inline in the string. Do we really need more complexity in cpp? isn't it complex enough?

discuss

order

mkoubaa|1 year ago

This is the sort of change that adds complexity to the language but reduces complexity in the code written in the language. We take those

hackyhacky|1 year ago

> This is the sort of change that adds complexity to the language but reduces complexity in the code written in the language. We take those

An admirable statement of policy, but I'm not sure it's possible. Adding complexity to the language means there are more gotchas and edge-cases that a programmer must consider, even if they don't use the feature in question.

puffybuf|1 year ago

how would this work with internationalized strings? especially if you have to change the order of things? You'd still need a string version with object ordering I would think

HeliumHydride|1 year ago

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.

rerdavies|1 year ago

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.

richrichardsson|1 year ago

So it's less complex bringing in a 3rd party library and having to pass arguments?

fmt library can also do something similar, but still requires the complexity of adding the library and passing arguments.

hyperpl|1 year ago

especially bringing in boost which isn't allowed in some codebases

nikhilsimha|1 year ago

just skimmed the proposal, dont see how inline rendered f-strings are more complicated than the alternative.