This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

allocators for hash_map, type inconsistency


Hello libstdc++,

  First of all I should note, that I tried to apply hash_map class to
  another standart STL compatible platform and recieved "inconsistent
  types" messages. Look at this, please:
    - Default template argument for 5th parameter has "allocator<_Tp>"
      type. Then this allocator is passed to hashtable class as an
      allocator ( 6th parameter of template definition ). And hash_map
      defines _Ht type as "hashtable< pair<const _Key,_Tp>,
                                     _Key,
                                     _HashFcn,
                                     _Select1st<pair<const _Key, _Tp> >,
                                     _EqualKey,
                                     _Alloc>"
      That is _Alloc = allocator<_Tp> here. Not even pair<_Key,_Tp>!!!
      In the hashtable class this allocator is used both to allocate
      memory for _Hashtable_node< pair<_Key,_Tp> > (called _Node) item
      and pointer in the std::vector<_Node*, _Alloc>

      So I've concluded that
        1) Allocator "allocator<_Tp>" is incorrect for _Node
           allocation.
        2) Allocator "allocator<_Tp>" is incorrect as vector<_Node*>
           allocator.
        3) These allocators should have different types, i.e. pointer
           and _Node, hence one cannot specify only one template
           parameter for hash_map class (or should find anther way to
           resolve this).
        4) I wanna know badly why such a construction works under GNU
           g++...
      If I misunderstanded something let me know please and explain me
      how to resolve this problem with other compiler.

-- 
Best regards,
 Alex                          mailto:dazhbog@chat.ru



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]