It seems they're targeting C++11?
It seems they're targeting C++11?
The string_view lookup is nearly done, but I did not want to wait for it, because it would have delayed the release even more.
I'm also working on supporting unordered_map - using it as container for objects would be easy if we would just break the existing API - the hard part is to support it with the current (probably bad designed) template API.
std::unordered_map has massive overhead in space and time. Maybe I misunderstand your idea, but outside of extremely niche use cases, std::unordered_map is basically never the right tool (unless you don't care in the slightest about performance or memory overhead).
https://stackoverflow.com/a/42588384/1593077
and the link there. Not sure that's what GP meant though.
And I don't like it when people use ridiculous hyperbole to describe what is in reality barely perceptible overhead, so it would be good if the person I originally responded to came out and defended his POV. Hopefully using actual numbers instead of agitated handwaving and screaming...
Pretty sure that makes it impossible to implement merge without pointer/iterator invalidation, which is a constraint imposed by the standard (https://en.cppreference.com/w/cpp/container/unordered_map/me...).
> it would be good if the person I originally responded to came out and defended his POV
See https://probablydance.com/2017/02/26/i-wrote-the-fastest-has... if you want numbers, or for example this talk by the same author https://www.youtube.com/watch?v=M2fKMP47slQ.
The issue is that the implementors won't change their implementation of unordered_map as it's an ABI break, to say it simply. It could be better. But also, there are other tools like flat maps/open addressing that are not done in the std library.
Not sure what your rationale is for saying it’s only useful for extremely niche use cases. I would be curious to know why you think so.
See https://www.youtube.com/watch?v=M2fKMP47slQ for a more comprehensive discussion, or the sibling threads here.
std::map is only useful if you need the data to be ordered, otherwise std::unordered_map is the right default choice.
> std::unordered_map has massive overhead in space and time.
Yes, std::unordered_map uses a bit more memory, but please show me some benchmarks where it is slower than std::map - especially with string keys!
BTW, for very small numbers of items the most efficient solution is often a plain std::vector + linear search.
This is why flat_map is a great solution. It's basically an ordered vector with a map-like interface, but without the memory allocation (and cache locality issues) for each node. Until you start getting into thousands of elements it is probably the best choice of container.
And ordered maps fall somewhere in the middle.
They might make sense if you're creating massive amounts of medium sized maps.
Or if you need range searches etc.
It's all compromises, there are no hard rules.
That's sometimes ok, particularly if you don't care about performance (beyond asymptotic behavior). But if you do, you'd probably be well-advised to try out hash map implementations that actually don't leave performance on the table by design.
You literally suggested to (almost) always prefer std::map...
> Every node has to be stored as separately allocated linked list entry.
But it's basically the same for std::map. Both containers have similar design constraints. I am aware that std::unordered_map uses more memory than std::map, but why should it be slower in the general case? After all, hashtables trade memory for speed.
> But if you do, you'd probably be well-advised to try out hash map implementations that actually don't leave performance on the table by design.
I agree. But the same is true for std::map (someone has already mentioned flat maps).
std::unordered_map is typically the go-to hash map on any given C++ day. You’re probably fine with std::map outside of large n
EDIT: being pedantic
But to be honest, I have not yet played around with PMR.
For example, C++/WinRT is a C++17 library, yet plenty of samples use C style strings and vectors.
Do you find it unreasonable to point out that what's been advertised doesn't match what's being offered?