How to construct a std::string with embedded values, i.e. “string interpolation”?

In C++20 you will be able to use std::format.

This will support python style formatting:

string s = std::format("{1} to {0}", "a", "b");

There is already an implementation available: https://github.com/fmtlib/fmt.

Leave a Comment