diff options
author | Nhat Nguyen <nhat7203@gmail.com> | 2024-08-01 14:08:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 14:08:21 -0400 |
commit | 8d151f804ff43aaed1edf810bb2a07607b8bba14 (patch) | |
tree | 53daac925ed49197545332f5face363bb370c591 /libcxx/test/std/algorithms/alg.nonmodifying | |
parent | 41439d5bb72f1f582df8887b37931720d7233298 (diff) | |
download | llvm-8d151f804ff43aaed1edf810bb2a07607b8bba14.zip llvm-8d151f804ff43aaed1edf810bb2a07607b8bba14.tar.gz llvm-8d151f804ff43aaed1edf810bb2a07607b8bba14.tar.bz2 |
[libc++] Check correctly ref-qualified __is_callable in algorithms (#73451)
We were only checking that the comparator was rvalue callable,
when in reality the algorithms always call comparators as lvalues.
This patch also refactors the tests for callable requirements and
expands it to a few missing algorithms.
Fixes #69554
Diffstat (limited to 'libcxx/test/std/algorithms/alg.nonmodifying')
3 files changed, 17 insertions, 9 deletions
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp index ea4270e..4e4f889 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp @@ -51,7 +51,7 @@ struct S { }; struct eq { - bool operator()(const S& a, const S&b) { return a.i_ == b.i_; } + bool operator()(const S& a, const S& b) const { return a.i_ == b.i_; } }; diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp index 3bf72e3..2fa3e9f 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp @@ -32,12 +32,13 @@ TEST_CONSTEXPR bool test_constexpr() { } #endif -struct count_equal -{ - static unsigned count; - template <class T> - bool operator()(const T& x, const T& y) - {++count; return x == y;} +struct count_equal { + static unsigned count; + template <class T> + bool operator()(const T& x, const T& y) const { + ++count; + return x == y; + } }; unsigned count_equal::count = 0; diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp index f835d2f..cfb82f3 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp @@ -36,8 +36,15 @@ struct count_equal { static unsigned count; template <class T> - bool operator()(const T& x, const T& y) - {++count; return x == y;} + bool operator()(const T& x, const T& y) & { + ++count; + return x == y; + }; + template <class T> + bool operator()(const T& x, const T& y) const& { + ++count; + return x == y; + }; }; unsigned count_equal::count = 0; |