This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++14 status.
allocator_traits to define member typesSection: 23.5[unord]Status:C++14Submitter: Tom ZiebermanOpened: 2011-04-29Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [unord].
View all issues withC++14 status.
Discussion:
The unordered associative containers define their member typesreference,const_reference,pointer,const_pointer in terms of their template parameterAllocator (viaallocator_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 definingpointer andconst_pointer typedefs in terms ofallocator_traits<Allocator> and by definingreference andconst_reference in terms ofvalue_type as is done in the other containers.
[2011 Bloomington.]
Move to Ready.
Proposed resolution:
This wording is relative to the FDIS.
Change 23.5.3.1[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 typenameallocator_typeallocator_traits<Allocator>::pointer pointer; typedef typenameallocator_typeallocator_traits<Allocator>::const_pointer const_pointer; typedeftypename allocator_type::referencevalue_type& reference; typedeftypename allocator_type::const_referenceconst value_type& const_reference; typedefimplementation-defined size_type; typedefimplementation-defined difference_type; […] };}Change 23.5.4.1[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 typenameallocator_typeallocator_traits<Allocator>::pointer pointer; typedef typenameallocator_typeallocator_traits<Allocator>::const_pointer const_pointer; typedeftypename allocator_type::referencevalue_type& reference; typedeftypename allocator_type::const_referenceconst value_type& const_reference; typedefimplementation-defined size_type; typedefimplementation-defined difference_type; […] };}Change 23.5.6.1[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 typenameallocator_typeallocator_traits<Allocator>::pointer pointer; typedef typenameallocator_typeallocator_traits<Allocator>::const_pointer const_pointer; typedeftypename allocator_type::referencevalue_type& reference; typedeftypename allocator_type::const_referenceconst value_type& const_reference; typedefimplementation-defined size_type; typedefimplementation-defined difference_type; […] };}Change 23.5.7.1[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 typenameallocator_typeallocator_traits<Allocator>::pointer pointer; typedef typenameallocator_typeallocator_traits<Allocator>::const_pointer const_pointer; typedeftypename allocator_type::referencevalue_type& reference; typedeftypename allocator_type::const_referenceconst value_type& const_reference; typedefimplementation-defined size_type; typedefimplementation-defined difference_type; […] };}