How to format string in boost library

Viewed 15528

I want to format string with boost library in C++. I am doing as below.

std::string msg = "Version: %1. Version %2.";
boost::format formatter(msg.c_str());
formatter % "v1" % "v2";
xyz_function(msg);

We can do that with sprintf in one statement so is there a way to optimize above boost implementation for string formation in one statement or something other ?

Thanks in Advance.

1 Answers
Related