现在的位置: 首页 > 综合 > 正文

boost pool_allocator 报错 ‘rebind’

2013年12月12日 ⁄ 综合 ⁄ 共 630字 ⁄ 字号 评论关闭
#include "stdafx.h"

#include <vector>
#include <boost/pool/pool.hpp>

int _tmain(int argc, _TCHAR* argv[])
{
	std::vector<int, boost::pool_allocator<int>> v;
	return 0;
}

编译报错:

d:\program files\microsoft visual studio 10.0\vc\include\vector(421): error C2903: 'rebind' : symbol is neither a class template nor a function template

怀疑是pool_allocator与Vc的STL不兼容。

后来发现是应该使用pool_alloc.hpp头文件才行:

#include <boost/pool/pool_alloc.hpp>

Boost文档仅假定

// Include all of Pool files
#include <boost/pool.hpp>

实际上,boost/pool.hpp 不存在。

感叹模板类的编译错误信息太没头绪。

后来发现其中有一行错误:

d:\program files\microsoft visual studio 10.0\vc\include\vector(421): error C2027: use of undefined type 'boost::pool_allocator<T>'

为了这一行错误,总的出错报告接近400行。

抱歉!评论已关闭.