1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef SUPPORT_OPERATOR_HIJACKER_H
10 #define SUPPORT_OPERATOR_HIJACKER_H
15 #include "test_macros.h"
17 /// Helper struct to test ADL-hijacking in containers.
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; }
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>");
42 struct std::hash
<operator_hijacker
> {
43 std::size_t operator()(const operator_hijacker
&) const { return 0; }
46 #endif // SUPPORT_OPERATOR_HIJACKER_H