[libcxx-commits] [PATCH] D93557: [libc++] [P0879] constexpr std::nth_element, and rewrite its tests.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 18 10:53:39 PST 2020


Quuxplusone created this revision.
Quuxplusone added a reviewer: ldionne.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This patch is more than just adding the `constexpr` keyword, because the old code relied on `goto`, and `goto` is not constexpr-friendly. Refactor to eliminate `goto`, and then mark it as constexpr in C++20.

I freely admit that the name `__nth_element_partloop` is bad; I couldn't find any better name because I don't really know what this loop is doing, conceptually. Vice versa, I think `__nth_element_find_guard` has a decent name.

Now the only one we're still missing from P0879 is `sort`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93557

Files:
  libcxx/include/algorithm
  libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
  libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93557.312852.patch
Type: text/x-patch
Size: 15640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201218/49456fa3/attachment.bin>


More information about the libcxx-commits mailing list