-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: steal backing array in flat map/set #22
Comments
Thanks for the kind words!
Should not be too difficult to do. Let me look into it. |
Hum, there is the issue of the allocator used for allocating the array inside the flat_hash_set. If you steal the buffer, then you also need to use the same allocator to free the memory buffer eventually. I wish there was a way to construct a std::vector from a pointer, size, capacity and optional allocator. I don't want to implement my own But it would be nice, we could have a
and that move constructor would steal the underlying array (after compaction). |
Yeah, I figured it could be a super-low-level expert method where the caller may even be in charge of calling individual destructors (making it possible is better than nothing at all IMO). Either that, or as you suggest, your own little vector-like class. |
OK, I did the first part, added |
One feature that would greatly decrease peak memory usage in my use-case is to have the ability to "steal" the backing array from the flat-maps (after compacting them into a "normal" array first of course.)
The use-case is currently implemented as follows:
Perhaps something along the lines of:
Oh, and thank you for the inspired lazy_emplace()! It's still more powerful than other map/set implementations of try_emplace since key creation can be deferred or customized as well.
The text was updated successfully, but these errors were encountered: