Issues with unordered_map and unordered_multimap

Jonathan Wakely jwakely.gcc@gmail.com
Fri May 20 07:40:00 GMT 2016


On 20 May 2016 at 03:46, Pavel P wrote:
> Hi,
>
> I noticed that unordered_map with g++ (4.7 or 5.2) cannot be used with
> forward declared types:
>
> #include <unordered_map>
>
> class test;
> typedef std::unordered_map<int, test> test_map;
> typedef test_map::iterator test_map_iterator;  // <== error
>
> here's error output: https://ideone.com/sy05RG
>
> This same code works with std::map: https://ideone.com/poufNk
> As far as I understand standard doesn't require that it would work,
> still I think it would be nice that it worked similar to std::map. It
> works ok with MSVC by the way.

It would be nice, but it's not possible with our implementation, sorry.

> The other issue is with unordered_multimap. Not sure what's going on
> behind the scenes, but it was exceptionally slow in my case, and
> unorderedmap::operator[] was taking like 80% of CPU in my app. I ended
> up replacing it with unordered_map<lkey, list<value> > to solve it.
>
> Any ideas?.

No. Any details?

At a guess, I'd say you have tons of collisions, so the buckets are
getting very large. If you have some code to reproduce the problem we
can look at it, but the description above is far too vague to be
useful.



More information about the Libstdc++ mailing list