首先到boost官网去下载最新的版本的boost库:
http://www.boost.org/
1.解压boost压缩包
2.通过命令行进入boost库解压目录下,运行安装脚本bootstrap.bat
3.运行b2.exe(需要等一段时间)
4.bin.v2是编译产生的中间文件,可以删除(大约有3.5G)
打开VS2015,配置包含目录和库目录
测试代码:
#include <boost/lexical_cast.hpp>
#include <iostream>
using namespace std;
using namespace boost;
int main()
{
double a = lexical_cast<double>("3.1415926");
string str = lexical_cast<string>("3.1415926");
cout << "This is a number: " << a << endl;
cout << "This is a string: " << str << endl;
int b = 0;
try {
b = lexical_cast<int>("sh");
//b = lexical_cast<int>("5");
}
catch (bad_lexical_cast& e) {
cout << e.what() << endl;
}
system("pause");
return 0;
}