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 //===----------------------------------------------------------------------===// 8 9 #ifndef SUPPORT_OPERATOR_HIJACKER_H 10 #define SUPPORT_OPERATOR_HIJACKER_H 11 12 #include <cstddef> 13 #include <functional> 14 15 #include "test_macros.h" 16 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; } 23 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; 32 }; 33 34 template <> 35 struct std::hash<operator_hijacker> { 36 size_t operator()(const operator_hijacker&) const { return 0; } 37 }; 38 39 #endif // SUPPORT_OPERATOR_HIJACKER_H 40