#include <vector>
#include <functional>
int main(int argc, char** argc)
{
std::vector<int> x;
std::function<void (void)> f(std::allocator_arg,x.get_allocator());
return 1;
}
使用:g++ test.cpp -o test -std=c++11
它失敗了Ubuntu 15
,我g++ version is 5.2.1
。在XCode
和VS2015
上都可以。我檢查/usr/include/c++/5/functional
,它沒有分配器的構造函數。我檢查www.cplusplus.com
,並用分配器定義構造函數。
有人能告訴我如何解決這個問題,或者我必須要改變的G ++ STL, 如何更改與其他STL G ++ STL?我已經下載了sgi stl源代碼。
請幫忙!非常感謝 。爲什麼g ++在Ubuntu上不支持allocator構造函數的功能?
'allocator_arg'是一個常數 - 你的代碼是沒有更多的意義比'的std ::函數 F(PI);'。 –
直到GCC 6.1.0,帶分配器的'std :: function'仍然不被支持,源代碼有評論'// TODO:needs allocator_arg_t' – Mine
非常感謝。我放棄使用allocator〜 – NeoLiu