[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / utilities / function.objects / range.cmp / equal_to.pass.cpp
blob6d207548b2175055a205da8fbda9f22d7bc29308
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // <functional>
13 // ranges::equal_to
15 #include <cassert>
16 #include <functional>
17 #include <type_traits>
18 #include <utility>
20 #include "test_macros.h"
21 #include "compare_types.h"
22 #include "MoveOnly.h"
23 #include "pointer_comparison_test_helper.h"
25 struct NotEqualityComparable {
26 friend bool operator==(const NotEqualityComparable&, const NotEqualityComparable&);
27 friend bool operator!=(const NotEqualityComparable&, const NotEqualityComparable&) = delete;
30 static_assert(!std::is_invocable_v<std::ranges::equal_to, NotEqualityComparable, NotEqualityComparable>);
31 static_assert(!std::is_invocable_v<std::ranges::equal_to, int, MoveOnly>);
32 static_assert(std::is_invocable_v<std::ranges::equal_to, explicit_operators, explicit_operators>);
34 static_assert(requires { typename std::ranges::equal_to::is_transparent; });
36 constexpr bool test() {
37 auto fn = std::ranges::equal_to();
39 assert(fn(MoveOnly(42), MoveOnly(42)));
41 ForwardingTestObject a;
42 ForwardingTestObject b;
43 assert(!fn(a, b));
44 assert(fn(std::move(a), std::move(b)));
46 assert(!fn(1, 2));
47 assert(!fn(2, 1));
48 assert(fn(2, 2));
50 assert(!fn(2, 1L));
52 return true;
55 int main(int, char**) {
57 test();
58 static_assert(test());
60 // test total ordering of int* for equal_to<int*> and equal_to<void>.
61 do_pointer_comparison_test(std::ranges::equal_to());
63 return 0;