boost-使用format和lexical_cast实现数字和字符串之间的转换
使用boost的format可以实现数字到string的格式化转换,boost的lexical_cast可以实现string到数值的转换,eg:
#include "boost/format.hpp" #include "boost/lexical_cast.hpp" boost::format fmt("double value: %.2f"); double d = 12.34; std::string str = (fmt % d).str(); std::string strValue("12.34"); double i = boost::lexical_cast<double>(strValue);