[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / libcxx / test / support / operator_hijacker.h
blob34be330b056ad0f7016e4a4b1f670ed6f2a5e733
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 template <>
35 struct std::hash<operator_hijacker> {
36 size_t operator()(const operator_hijacker&) const { return 0; }
39 #endif // SUPPORT_OPERATOR_HIJACKER_H