
The Complete Guide to Building Strings in C++ - joboccara
https://www.fluentcpp.com/2017/12/19/build-strings-from-plain-string-up-to-boost-karma/
======
aldanor
I’m surprised at how the author fails to mention fmtlib [1] with near-printf-
like performance and sane (Python .format-like) formatting syntax, which also
happens to generate much smaller binaries than Boost.Format.

[1] [https://github.com/fmtlib/fmt](https://github.com/fmtlib/fmt)

------
Koshkin
Informative article. In practice, using ostringstream is the most useful
technique.

------
gumby
Author doesn't have a comment section unfortunately, perhaps he reads this.
Instead of the stream iterator, use a stream _joiner_ and not deal with the
crummy trailing delimiter.

Also to_chars offers better formatting than to_string.

~~~
gumby
to late to edit: there IS a comment section but my ad blocking had blocked it
-- and someone else pointed out the stream joiners.

------
signa11
cheap jabs at the venerable printf(...) notwithstanding, this article is ok.
however, i must confess, string formatting still sucks in plain C++, and
snprintf(...) is not too shabby.

~~~
reality_czech
The cheap jabs are all incorrect, as well. Any compiler from the last 10 years
will warn you if you don't match your printf format string to the arguments.
printf also supports reordering arguments using the %m$ syntax (read the man
page). And yes, you can extend printf with your own types.

A better guide to using strings in C++ is here:
[https://yosefk.com/c++fqa/io.html](https://yosefk.com/c++fqa/io.html)

~~~
nikbackm
Does the compiler also warn when you don't use a literal format string?

