STL question

Alexandre Oliva
Sat Sep 26 00:52:00 GMT 1998

Alexander Samoilov <spike@Gambit.Msk.SU> writes:

> typedef hash_map<char* const, int, hash<char*>, eqstr> hmap;

> int main() { hmap ins_diff;
>     insert_iterator<hmap> ii1(ins_diff,ins_diff.begin());

Unlike map, hash_map does not support insert(pos,x), so insert
iterators do not work on it :-(

Instead, you may want to replace ii1 with:

      bind1st(mem_fun(insert_meth), &ins_diff)


      pair<hmap::iterator,bool> (hmap::*insert_meth)(const hmap::value_type&)
	= &hmap::insert;
Perhaps insert iterators should be specialized for hash maps...

Alexandre Oliva
Universidade Estadual de Campinas, SP, Brasil

More information about the Gcc mailing list