【问题标题】:why unordered associative containers do not use allocator_traits<T> in C++0x为什么无序关联容器在 C++0x 中不使用 allocator_traits<T>
【发布时间】:2011-04-29 18:56:31
【问题描述】:

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

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

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

而无序的关联容器使用这个:

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

我错过了什么?

【问题讨论】:

    标签: c++ c++11 containers


    【解决方案1】:

    我不认为你错过了什么。这是您参与标准流程的机会。请提交问题。有关如何执行此操作的说明如下:

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

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

    【讨论】:

      【解决方案2】:

      这个问题现在在当前的最新草案中得到了纠正。例如第 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-06-05
        • 1970-01-01
        • 2011-05-23
        • 1970-01-01
        • 2017-08-17
        • 2011-08-16
        • 1970-01-01
        • 2013-12-24
        相关资源
        最近更新 更多