15775 – Allocator::pointer consistently ignored (original) (raw)
| Description Carlo Wood 2004-06-02 12:22:44 UTC Many (if not all) STL containers use typedefs like: typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; However, according to the standard it should be Allocator::pointer etc. For example, 23.2.1 Template class deque [lib.deque] says namespace std { template <class T, class Allocator = allocator > class deque { public: // types: typedef typename Allocator::reference reference; typedef typename Allocator::const_reference const_reference; // See 23.1 typedef implementation defined iterator; const_iterator; // See 23.1 typedef implementation defined // See 23.1 typedef implementation defined size_type; difference_type; // See 23.1 typedef implementation defined typedef T value_type; typedef Allocator allocator_type; typedef typename Allocator::pointer pointer; typedef typename Allocator::const_pointer const_pointer; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; and since Allocator is a user specified class, it cannot be correct to replace these 'typename Allocator::pointer' with 'value_type*'. Comment 1 Paolo Carlini 2004-06-09 09:45:33 UTC Confirmed: for some reason, when fixing libstdc++/13462 we didn't notice that the problem was more general. Comment 2 Paolo Carlini 2004-06-09 10:10:47 UTC Notice, however, that at variance with the specific cases fixed for 13462, the remaining containers are essentially ok (i.e., the change is only cosmetic) due to the Standard requirements for allocators (Table 32): allocator::pointer is required to be T*, for instance. Comment 4 Benjamin Kosnik 2004-06-09 22:05:19 UTC paolo can you put this on gcc-3_4-branch too, at some date before 3.4.1? thanks, benjamin Comment 6 Paolo Carlini 2004-06-11 18:46:22 UTC Fixed for 3.4.1. | | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |