【发布时间】:2015-03-04 09:46:50
【问题描述】:
我想使用与unordered_map 中的默认值不同的allocator。
对于我的特定allocator,我想调用另一个构造函数而不是默认构造函数(我想将int 传递给构造函数)。
我认为问题在于unordered_map 调用了我的default constructor 的default constructor。
所以,最终我想做这样的事情:
而不是调用这个unordered_map构造函数:
std::tr1::unordered_map<int, int, std::tr1::hash<int>, std::equal_to<int>, MyAllocatorNs::MyAllocator<std::pair<const int, int> > > unorderedMap;
我想做这样的事情:
std::tr1::unordered_map<int, int, std::tr1::hash<int>, std::equal_to<int>, MyAllocatorNs::MyAllocator<std::pair<const int, int> >(3) > unorderedMap;
有可能吗?
【问题讨论】:
标签: c++ templates c++11 unordered-map tr1