-
Notifications
You must be signed in to change notification settings - Fork 52
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
Initial implementation of P1222R1 flat_set from Zach Laine's paper
#148
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4fcbd08
to
dc6aad5
Compare
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1222r1.pdf Notice that some of the wording is actually in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0429r6.pdf so you need to look at both papers. Needs tests, of course!
tzlaine/draft#7 This is NOT editorial! It triggers blanket wording in https://eel.is/c++draft/associative.reqmts#15.2 https://eel.is/c++draft/container.adaptors.general#4.4 https://eel.is/c++draft/container.adaptors.general#4.5 The guides taking `Container` parameters are still nonsense; see tzlaine/flat_map#9
GCC eagerly evaluates expressions cast to `void`, but correctly lazily evaluates expressions comma'ed to `void`. https://godbolt.org/z/FPovlu
…ntainers. The old wording was in terms of "default-construct a KeyContainer `temp`, then swap it with `c`." The swap will have undefined behavior whenever `temp`'s default-constructed allocator is not equal to `c`'s allocator. This is generally expected to be the case when KeyContainer is anything with `std::pmr` in the name (e.g. `std::pmr::vector`). tzlaine/draft#5
flat_set.h(291): warning C4459:
declaration of 'sorted_unique' hides global declaration
This diagnostic seems crazy aggressive, but, okay then.
Eliminate calls to std::forward and std::move for compilation speed.
And drive-by fix a build failure on my local Xcode by moving the declaration of this `operator<` above the reference to a template instantiation that causes `operator<` to be looked up. No idea whether this is sane, but it works.
The result type of `std::rbegin(c_)` might not be the same as `std::reverse_iterator<decltype(c_.begin())>`, so we'd better be explicit. Also, use `c_.begin()` instead of `std::begin(c_)` everywhere for consistency. (All container types have a `.begin()` method.)
93cf099
to
96431c0
Compare
- The non-`sorted_unique` constructors/inserters must not only sort the container but unique it also. - The swap operation can assume that the container is nothrow-swappable, but not that the comparator is. - After a successful `extract()`, the container must be emptied (not left in a valid-but-unspecified state) in order to preserve our sorted-and-uniqued invariant. Implementation note: In C++14 we have to provide our own `is_nothrow_swappable` because otherwise we would either incorrectly tag our swap as `noexcept` when it could throw (leading to aborts), or incorrectly tag our swap as `noexcept(false)` when it should actually have been `noexcept` (which is almost worse).
This is really horrible. I'm not at all convinced that I'm doing the right thing here. tzlaine/flat_map#11
And fix a missing `return` in the two-iterator `erase` method.
|
Squash-merged 8df31aa (both |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From this paper: P1222R1 "A Standard
flat_set" (January 2019).Notice that some of the wording is actually in P0429R6 "A Standard
flat_map" (January 2019), so you need to look at both papers.Needs tests, of course!
TODOcomments mark the places where there are bugs in P1222R1 and they aren't 100% obvious typos. (I quietly fixed several 100% obvious typos.)