stringstream完全适用, boost::format感觉代码可读性不好,可能还不习惯吧
#include <iostream>
#include <boost/format.hpp>
#include <string>
#include <sstream>
int _tmain(int argc, _TCHAR* argv[])
{
std::string str = "sum";
int i = 100, j = 200;
std::cout << boost::format("%s:%d+%d=%d")%str%i%j%(i+j) << std::endl;
boost::format fm("product:%1% * %2% = %3%");
std::cout << fm %3 %5 %(3*5) << std::endl;
int *p = &i;
std::cout << boost::format("address:0x%x")%p << std::endl;
std::stringstream ss;
ss << str << ":" << i << "+" << j << "=" << i+j;
std::cout << ss.str() << std::endl;
system("pause");
return 0;
}