为什么无序关联容器不使用<T> C++0x 中的allocator_traits

why unordered associative containers do not use allocator_traits<T> in C++0x

本文关键字:C++0x gt 中的 allocator traits 无序 lt 为什么 关联      更新时间:2023-10-16

为什么c++ 0x无序关联容器不使用allocator_traits来定义其成员类型指针和const_pointer?

例如,顺序关联容器和有序关联容器使用以下定义:

typedef typename allocator_traits<Allocator>::pointer pointer;
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;

而无序关联容器使用this:

typedef typename Allocator::pointer pointer;
typedef typename Allocator::const_pointer const_pointer;

我错过了什么?

我不认为你错过了什么。这是你参与标准制定过程的机会。请提交一个问题。关于如何这样做的说明在这里:

http://lwg.github.com/issues/lwg-active.html submit_issue

我扫描了,但没有找到关于这个主题的现有问题。

现在在最新的草案中更正了这一点。例如第788页:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3376.pdf

class unordered_set
{
public:
// types
.... .... .... 
typedef typename allocator_traits<Allocator>::pointer pointer;
typedef typename allocator_traits<Allocator>::const_pointer const_pointer;
.... .... ....
}

有趣的是,en.cppreference.com(你可能会认为不正确)同意:http://en.cppreference.com/w/cpp/container/unordered_map