#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;
}
#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 不存在。#include <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行。