This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Issues with unordered_map and unordered_multimap
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Pavel P <pavlov dot pavel at gmail dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 20 May 2016 08:39:50 +0100
- Subject: Re: Issues with unordered_map and unordered_multimap
- Authentication-results: sourceware.org; auth=none
- References: <CAG_s-qqg=4vhdZfcsHFY_+bHCNi=NnDSj0jA1G6JrCQ_sVsigA at mail dot gmail dot com>
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.