C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal for std::(set / map / multiset / multimap)::partition_point

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Tue, 11 Jun 2024 20:28:32 +0100
On Tue, 11 Jun 2024, 20:02 Aeren via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> Hi, this is my first proposal to C++ STL and I'm looking forward to
> getting some feedback :)
>
> std::lower_bound / std::upper_bound lets you binary search on a range
> defined by a pair of legacy random access iterators, and we have a BBST
> counterpart for this: std::(set / map / multiset / multimap)::(lower_bound
> / upper_bound)
>
> I would like to propose to add the BBST counterpart of
> std::partition_point, which generalizes both std::lower_bound and
> std::upper_bound.
>
> This addition would let us binary search on dynamically changing points
> with an arbitrary binary predicate on which the points are "partitioned".
>

What would be your proposed API, what would the precise semantics be, and
what are the motivating use cases?



> Currently, there's a workaround for this using the signature (3) and (4)
> on cppreference lower_bound doc
> <https://en.cppreference.com/w/cpp/container/set/lower_bound>. However,
> it is very ugly to do this because it forces K and x to be meaningless and
> forces me to define a weird comparator with K.
>
> Thank you for taking your time to read this proposal :)
> Aeren
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-06-11 19:29:54