Title
Unordered associative containers do not use allocator_traits to define member types
Status
c++14
Section
[unord]
Submitter
Tom Zieberman

Created on 2011-04-29.00:00:00 last changed 123 months ago

Messages

Date: 2011-08-16.23:35:18

Proposed resolution:

This wording is relative to the FDIS.

  • Change [unord.map.overview] paragraph 3 as indicated:

    namespace std {
      template <class Key,
                class T,
                class Hash = hash<Key>,
                class Pred = std::equal_to<Key>,
                class Allocator = std::allocator<std::pair<const Key, T> > >
      class unordered_map
      {
      public:
        // types
        typedef Key key_type;
        typedef std::pair<const Key, T> value_type;
        typedef T mapped_type;
        typedef Hash hasher;
        typedef Pred key_equal;
        typedef Allocator allocator_type;
        typedef typename allocator_typeallocator_traits<Allocator>::pointer pointer;
        typedef typename allocator_typeallocator_traits<Allocator>::const_pointer const_pointer;
        typedef typename allocator_type::referencevalue_type& reference;
        typedef typename allocator_type::const_referenceconst value_type& const_reference;
        typedef implementation-defined size_type;
        typedef implementation-defined difference_type;
    
        […]
      };
    }
    
  • Change [unord.multimap.overview] paragraph 3 as indicated:

    namespace std {
      template <class Key,
                class T,
                class Hash = hash<Key>,
                class Pred = std::equal_to<Key>,
                class Allocator = std::allocator<std::pair<const Key, T> > >
      class unordered_multimap
      {
      public:
        // types
        typedef Key key_type;
        typedef std::pair<const Key, T> value_type;
        typedef T mapped_type;
        typedef Hash hasher;
        typedef Pred key_equal;
        typedef Allocator allocator_type;
        typedef typename allocator_typeallocator_traits<Allocator>::pointer pointer;
        typedef typename allocator_typeallocator_traits<Allocator>::const_pointer const_pointer;
        typedef typename allocator_type::referencevalue_type& reference;
        typedef typename allocator_type::const_referenceconst value_type& const_reference;
        typedef implementation-defined size_type;
        typedef implementation-defined difference_type;
    
        […]
      };
    }
    
  • Change [unord.set.overview] paragraph 3 as indicated:

    namespace std {
      template <class Key,
                class Hash = hash<Key>,
                class Pred = std::equal_to<Key>,
                class Allocator = std::allocator<Key> >
      class unordered_set
      {
      public:
        // types
        typedef Key key_type;
        typedef Key value_type;
        typedef Hash hasher;
        typedef Pred key_equal;
        typedef Allocator allocator_type;
        typedef typename allocator_typeallocator_traits<Allocator>::pointer pointer;
        typedef typename allocator_typeallocator_traits<Allocator>::const_pointer const_pointer;
        typedef typename allocator_type::referencevalue_type& reference;
        typedef typename allocator_type::const_referenceconst value_type& const_reference;
        typedef implementation-defined size_type;
        typedef implementation-defined difference_type;
    
        […]
      };
    }
    
  • Change [unord.multiset.overview] paragraph 3 as indicated:

    namespace std {
      template <class Key,
                class Hash = hash<Key>,
                class Pred = std::equal_to<Key>,
                class Allocator = std::allocator<Key> >
      class unordered_multiset
      {
      public:
        // types
        typedef Key key_type;
        typedef Key value_type;
        typedef Hash hasher;
        typedef Pred key_equal;
        typedef Allocator allocator_type;
        typedef typename allocator_typeallocator_traits<Allocator>::pointer pointer;
        typedef typename allocator_typeallocator_traits<Allocator>::const_pointer const_pointer;
        typedef typename allocator_type::referencevalue_type& reference;
        typedef typename allocator_type::const_referenceconst value_type& const_reference;
        typedef implementation-defined size_type;
        typedef implementation-defined difference_type;
    
        […]
      };
    }
    
Date: 2011-08-16.23:35:18

[ 2011 Bloomington. ]

Move to Ready.

Date: 2011-05-03.17:43:05

The unordered associative containers define their member types reference, const_reference, pointer, const_pointer in terms of their template parameter Allocator (via allocator_type typedef). As a consequence, only the allocator types, that provide sufficient typedefs, are usable as allocators for unordered associative containers, while other containers do not have this deficiency. In addition to that, the definitions of said typedefs are different from ones used in the other containers. This is counterintuitive and introduces a certain level of confusion. These issues can be fixed by defining pointer and const_pointer typedefs in terms of allocator_traits<Allocator> and by defining reference and const_reference in terms of value_type as is done in the other containers.

History
Date User Action Args
2014-02-20 13:20:35adminsetstatus: wp -> c++14
2012-02-12 18:36:43adminsetstatus: voting -> wp
2012-02-09 04:07:48adminsetstatus: ready -> voting
2011-08-16 23:35:18adminsetmessages: + msg5854
2011-08-16 23:35:18adminsetstatus: new -> ready
2011-04-30 10:59:24adminsetmessages: + msg5761
2011-04-29 00:00:00admincreate