标签:pause 管理器 art null time _each out cout space
由于boost都是使用模板的技术,所以全部代码都是写在一个.hpp头文件里。这样boost中的大部分内容是不须要编译生成对应的链接库,仅仅须要设置以下的包括文件夹(或者设置一下环境变量),在源文件里包括对应的头文件就能够使用了。
少部分库须要生成链接库来使用。
以下介绍完整安装boost库的方法:
1、首先到boost官网去下载最新的版本号的boost库:
2、解压文件。在命令提示符中打开到boost库的根文件夹下:
双击bootstrap.bat文件,生成bjam.exe,运行下面命令:
bjam --toolset=msvc --build-type=complete stage
或者直接双击bjam.exe.
等待程序编译完毕,大约要两个小时左右。会在boost根文件夹下生成bin.v2和stage两个文件夹。当中bin.v2下是生成的中间文件,大小在2.7G左右,能够直接删除。stage下才是生成的dll和lib文件。
3、打开vs:
视图->属性管理器->当前项目->Debug|Win32->Microsoft.Cpp.Win32.user双击
在弹出的属性对话框中:
通用属性->VC++文件夹:"包括文件夹": boost的根文件夹。例: D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0
"库文件夹": stage下的链接库文件夹。例:D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0\stage\lib
通用属性->链接器->常规:"附加库文件夹":同上面的"库文件夹",例:D:\Visual Stdio 2013\lipeng\boost\boost_1_58_0\stage\lib
至此环境就配置好了。以下測试一下:
<span style="font-size:14px;"><pre name="code" class="cpp"><span style="font-family:Courier New;">#include <cstdlib>
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <boost/timer.hpp>
#include <boost/progress.hpp>
#include <libs/date_time/src/gregorian/greg_names.hpp>
#include <libs/date_time/src/gregorian/date_generators.cpp>
#include <libs/date_time/src/gregorian/greg_month.cpp>
#include <libs/date_time/src/gregorian/gregorian_types.cpp>
#include <boost/date_time/posix_time/posix_time.hpp>
using namespace boost;
int main()
{
boost::timer t;
boost::progress_display pd(100);
for (int i = 0; i < 100; ++i) //进度条
{
++pd;
}
boost::gregorian::date dt(2009, 12, 8); //date_time 库
assert(dt.year() == 2009);
assert(dt.day() == 8);
boost::gregorian::date::ymd_type ymd = dt.year_month_day();
std::cout<<"\n"<<ymd.year<<"/"<<ymd.month<<"/"<<ymd.day<<" the day is "
<<dt.day_of_year() <<" days of this year"<< std::endl;
std::cout << boost::gregorian::to_iso_extended_string(dt) << std::endl; //转换为其它格式
std::cout << boost::gregorian::to_iso_string(dt) << std::endl;
std::cout << boost::gregorian::to_simple_string(dt) << std::endl<<std::endl;
//对数组排序操作
std::vector<int> test_vc(100);
std::vector<int>::iterator beg_it = test_vc.begin();
std::vector<int>::iterator end_it = test_vc.end();
std::srand(std::time(NULL));
std::for_each(beg_it, end_it, [](int& n){n = rand(); });
std::copy(beg_it, end_it, std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl << std::endl;
std::sort(beg_it, end_it, std::greater<int>());
std::copy(beg_it, end_it, std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl<<std::endl;
boost::posix_time::ptime pt(boost::gregorian::date(2005, 2, 6));
std::cout << t.elapsed() << "s" << std::endl; //程序执行时间
system("pause");
return 0;
}</span></span>程序正确执行:
标签:pause 管理器 art null time _each out cout space
原文地址:http://www.cnblogs.com/ljbguanli/p/7039890.html