[libc++][ranges] fix std::search_n incorrect static_assert
see more detail in https://reviews.llvm.org/D124079?#3661721
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp | ||
---|---|---|
181–189 | Nit: can we give a better name to this function? |
libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp | ||
---|---|---|
181–189 | Any suggestions? I agree it is a terrible name. It is my failed attempt to give it a reasonable name |
libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp | ||
---|---|---|
181–189 | Maybe test_binary_predicate_callable? Note the camel case instead to match that of test_constexpr for example. |
Should we add a similar test in std::search and others that have a similar pattern?
libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp | ||
---|---|---|
181–189 | 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); } |
std::search takes two ranges so it is slightly different. But yes it is worthwhile checking other algorithms which take a range and a value to see if they work properly
libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp | ||
---|---|---|
181–189 | good suggestion. thanks |
Nit: can we give a better name to this function?