[all-commits] [llvm/llvm-project] 207d4b: [libc++] [P0879] constexpr std::nth_element, and r...

Quuxplusone via All-commits all-commits at lists.llvm.org
Thu Jan 28 09:04:48 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 207d4be4d9d39fbb9aca30e5d5d11245db9bccc1
      https://github.com/llvm/llvm-project/commit/207d4be4d9d39fbb9aca30e5d5d11245db9bccc1
  Author: Arthur O'Dwyer <arthur.j.odwyer at gmail.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

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

  Log Message:
  -----------
  [libc++] [P0879] constexpr std::nth_element, and rewrite its tests.

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`.

Differential Revision: https://reviews.llvm.org/D93557




More information about the All-commits mailing list