I'm porting my code which written in cpp to support ARM9 using ADS 1.2 compiler,but after porting the below code gives error while compiling for ARM11 using RVCT2.2 compiler, this is the sample code
list<int,allocator<int> > mystack;
map<int*,list<int,allocator<int> >,less<int*>,allocator<pair<int*,list<int,allocator<int> > > > > mymap;
mymap[addr] = mystack;
Error 1:Error: #167:argument of type "std::allocator<std::pair<int *,
std::list<int, std::allocator<int>>>>::const_pointer" is incompatible with
parameter of type "std::allocator<std::pair<int *, std::list<int,
std::allocator<int>>>>::pointer"
Error 2:Error: #434: a reference of type
"__rw::__rw_tree_iter<__rw::__rb_tree<std::map<int *, std::list<int,
std::allocator<int>>, std::less<int *>, std::allocator<std::pair<int *,
std::list<int, std::allocator<int>>>>>::key_type, std::map<int *,
std::list<int, std::allocator<int>>, std::less<int *>,
std::allocator<std::pair<int *, std::list<int,
std::allocator<int>>>>>::value_type, (not const-qualified) cannot be
initialized with a value of type "std::map<int *, std::list<int,
std::allocator<int>>, std::less<int *>, std::allocator<std::pair<int *,
std::list<int, std::allocator<int>>>>>::value_type"
return _C_node->_C_value();
The problem you have is the allocator for
std::mapneeds to be pair ofRight not you have
Which is not the same as you do not have the
Keyconst qualified. It should beSince you are using the standard allocator there is no reason to specify the allocator. You can just use
And the list will default to using a
std::allocator<int>and the map will default to usingstd::less<int*>andstd::allocator<int * const, std::list<int>>Also not that
std::less<int*>do not compare the values theint*points to but instead it compares the address. If you need the former you need to write your own comparison object to do that.