-
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
Add a slot_map::partition(Pred) member function #133
base: master
Are you sure you want to change the base?
Conversation
05799bd
to
784dbdb
Compare
784dbdb
to
284bbfe
Compare
284bbfe
to
f6ca140
Compare
Just like the standard `std::partition` algorithm, this member function reorders the slot_map's elements in such a way that all elements for which the predicate `pred` returns `true` precede the elements for which `pred` returns `false`. The relative order of the elements is not preserved. The function returns an iterator to the first element of the second group (which may be `end()`, in the case that all elements belong to the first group). Addresses part of WG21-SG14#131, although I'm not sure whether this really addresses whatever use case @p-groarke is thinking of.
TBH, I'm not sure this is need. |
That would be great, but off the top of my head, would
|
Oh yes your right, that's why we needed this. Sorry, been a long time :) |
@@ -278,6 +278,46 @@ class slot_map | |||
return 1; | |||
} | |||
|
|||
constexpr void underlying_swap(const_iterator cit, const_iterator cjt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment and complexity would be nice to conform to the rest of the header.
} | ||
|
||
template<class Pred> | ||
constexpr iterator partition(const Pred& pred) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments and complexity would be welcome.
@Quuxplusone Please take a look at #147 |
Just like the standard
std::partition
algorithm, this member functionreorders the slot_map's elements in such a way that all elements for which
the predicate
pred
returnstrue
precede the elements for whichpred
returns
false
. The relative order of the elements is not preserved.The function returns an iterator to the first element of the second group
(which may be
end()
, in the case that all elements belong to the first group).Addresses part of #131, although I'm not sure whether this really addresses
whatever use case @p-groarke is thinking of.