I first encountered that idea in this classic Joel on Software post, which rather put me off the idea of using them in production:
> Notice in this case you’ve got a string that is null terminated (the compiler did that) as well as a Pascal string. I used to call these fucked strings because it’s easier than calling them null terminated pascal strings but this is a rated-G channel so you will have use the longer name.
> Lazy programmers would do this, and have slow programs
char* str = "*Hello!";
str[0] = strlen(str) - 1;
Modern compilers understand strlen, and will replace the function call with a constant where possible. That code's not slow anymore: https://godbolt.org/z/Kjh8b44KfBut Joel was talking about C rather than C++, where your comments about std::string wouldn't apply, right?
So long as the format string is a literal you needn't care how it works.
Now, one of the places where C makes this nastier than it needed to be is that C built-in types are silly, and so any non-trivial program is using better fundamental types like uint32_t (or the more succinct u32), for which the built-in formatter offers no syntax. So you end up writing format strings like "There are "PRIu32" dogs\n" using macros to bring in the appropriate specifier for your literal. Blergh.