This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
SGI hash_map extension bug with allocators
- To: libstdc++ at gcc dot gnu dot org
- Subject: SGI hash_map extension bug with allocators
- From: Alex <dazhbog at chat dot ru>
- Date: Tue, 13 Mar 2001 15:13:41 +0300
- CC: libstdc++ at sourceware dot cygnus dot com
- Reply-To: Alex <dazhbog at chat dot ru>
Hello libstdc++,
Does anyone tell me how to fix the problem with SGI extension
hash_map allocators?
The problem is in followed:
1) Definition of hash_map class looks like
hash_map <key_type, value_type, hasher, equality, allocator_type>
By default allocator_type = allocator<value_type>.
2) hash_map has member _M_ht of hashtable <pair <key_type,
value_type>, hasher, extractor, equality, allocator_type> type.
3) hashtable has member _M_buckets of vector<_Node*,
_M_buckets_allocator_type > type, where _Node is a typedef of
_Hastable_node struct.
The case is in that all allocators in hash_map, hashtable and
vector<_Node*> have the same type, allocator<hash_map::value_type>.
And even more the same allocator is used to create _Node object
inside hashtable method. MSVC 6.0 compiler gets an error message of
inconsistent types.
Actualy in hash_map class only two types of allocators are needed
and both are used in hashtable class.
- First to construct hash table of vector<_Node*> itself
(should be allocator<hashtable::value_type*> =
allocator<pair<hash_map::key_type, hash_map::value_type>*>).
- Second to create _Node object allocator<_Node>.allocate( 1, NULL )
(should be allocator<_Node> =
allocator<_Hastable_node<hashtable::value_type>> =
allocator<_Hastable_node<pair<hash_map::key_type,hash_map::value_type>>>).
But allocator which came from hash_map is
allocator<hash_map::value_type>, i.e. absolutely incorrect
allocator. Instead of it one of the two mentioned above allocators
should be used but which one?
How to resolve such a problem? In my task I used to take
allocator<pair<key_type,value_type> as a default allocator for
hash_map class to create _Node objects and to construct
vector<_Node*> with STL default allocator for <_Node*>. But such
method is in contradiction with the main principle of STL allocators
because vector<> is not possible to create here with user defined
allocator.
--
Best regards,
Alex mailto:dazhbog@chat.ru