boost vs2019

以1.72为例

下载地址

https://www.boost.org/users/history/version_1_72_0.html

解压

在开始菜单中打开Visual Studio 2019下的x64 Native Tools Command Prompt for VS 2019(其实其他的几个可不可以我也不知道,反正我用这个试的)

cd 到boost位置

输入

bootstrap.bat
.\b2

 成功后,应该类似这样

记住include paths和linker library paths

打开vs,

扫描二维码关注公众号,回复: 9756957 查看本文章

包含目录中输入include paths的路径(如D:\boost_1_72_0)

在库目录中输入linker library paths的路径(如D:\boost_1_72_0\stage\lib)

测试

#include <iostream>
#include <cassert>
#include <boost/sort/sort.hpp>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;
template<typename T>
void measure(T&& func) {
	using namespace chrono;
	auto start = system_clock::now();
	func();
	duration<double> diff = system_clock::now() - start;
	cout << "elapsed" << diff.count() << "seconds" << endl;
}
int main() {
	const int N = 1000000;
	random_device rd;
	vector<int> test;
	vector<int> ans;
	for (int i = 0; i < N; ++i) {
		int temp = rd() % 100000;
		test.push_back(temp);
		ans.push_back(temp);
	}
	measure([&ans]() {
		sort(ans.begin(), ans.end());
	});
	measure([&test]() {
		boost::sort::block_indirect_sort(test.begin(), test.end());	
	});
	
	for (int i = 0; i < N; ++i) {
		assert(test[i] == ans[i]);
	}
	return 0;
}

 debug x86

debug x64 

 

release x86 

 

release x64 

 

发布了93 篇原创文章 · 获赞 83 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_39942341/article/details/103848074