[libcxx-commits] [PATCH] D130124: [libc++][ranges] fix `std::search_n` incorrect `static_assert`

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 19 14:40:03 PDT 2022


ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

Should we add a similar test in `std::search` and others that have a similar pattern?



================
Comment at: libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp:189
     test<random_access_iterator<const int*> >();
-
+    testStaticAssertBug();
 #if TEST_STD_VER > 17
----------------
jloser wrote:
> huixie90 wrote:
> > jloser wrote:
> > > Nit: can we give a better name to this function?
> > Any suggestions? I agree it is a terrible name. It is my failed attempt to give it a reasonable name
> Maybe `test_binary_predicate_callable`? Note the camel case instead to match that of `test_constexpr` for example.
Suggestion -- don't give it a name. Define it in `main` like this instead:

```
// test bug reported in https://reviews.llvm.org/D124079?#3661721
{
  A a[]       = {A(1, 2), A(2, 3), A(2, 4)};
  int value   = 2;
  auto result = std::search_n(a, a + 3, 1, value, Pred());
  assert(result == a + 1);
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130124



More information about the libcxx-commits mailing list