[libcxx-commits] [PATCH] D124079: [libc++] Implement ranges::find_end, ranges::search{, _n}

Bogdan Graur via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 19 01:02:31 PDT 2022


bgraur added a comment.

Hi @philnik,

This commit breaks `std::search_n()`.

Reproducer:

  #include <algorithm>
  #include <vector>
  
  class A {
   public:
    A(int x, int y) : x_(x), y_(y) {}
    int x() const { return x_; }
    int y() const { return y_; }
  
   private:
    int x_;
    int y_;
  };
  
  bool search(const std::vector<A>& a, int value) {
    return std::search_n(a.begin(), a.end(), 1, value,
                         [](const A& l, int r) { return l.x() == r; }) == a.end();
  }

Compile command:

  clang  -std=gnu++17  -c /tmp/test.cc  -o /tmp/a.o 

That should compile according to https://en.cppreference.com/w/cpp/algorithm/search_n but it no longer does after this commit.
It compiles correctly with the commit before.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124079/new/

https://reviews.llvm.org/D124079



More information about the libcxx-commits mailing list