Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / support / operator_hijacker.h
bloba2569da0310fff9b2e40cee2db8426548f94ff61
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 #ifndef SUPPORT_OPERATOR_HIJACKER_H
10 #define SUPPORT_OPERATOR_HIJACKER_H
12 #include <cstddef>
13 #include <functional>
15 #include "test_macros.h"
17 /// Helper struct to test ADL-hijacking in containers.
18 ///
19 /// The class has some additional operations to be usable in all containers.
20 struct operator_hijacker {
21 bool operator<(const operator_hijacker&) const { return true; }
22 bool operator==(const operator_hijacker&) const { return true; }
24 template <typename T>
25 friend void operator&(T&&) = delete;
26 template <class T, class U>
27 friend void operator,(T&&, U&&) = delete;
28 template <class T, class U>
29 friend void operator&&(T&&, U&&) = delete;
30 template <class T, class U>
31 friend void operator||(T&&, U&&) = delete;
34 static_assert(std::is_trivially_copyable<operator_hijacker>::value && //
35 std::is_copy_constructible<operator_hijacker>::value && //
36 std::is_move_constructible<operator_hijacker>::value && //
37 std::is_copy_assignable<operator_hijacker>::value && //
38 std::is_move_assignable<operator_hijacker>::value, //
39 "does not satisfy the requirements for atomic<operator_hijacker>");
41 template <>
42 struct std::hash<operator_hijacker> {
43 std::size_t operator()(const operator_hijacker&) const { return 0; }
46 #endif // SUPPORT_OPERATOR_HIJACKER_H