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// <unordered_map>
10
11// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12// class Alloc = allocator<pair<const Key, T>>>
13// class unordered_map
14
15// Validate the constructors of the (const)(_local)_iterator classes to be
16// properly guarded against ADL-hijacking operator&.
17
18#include <unordered_map>
19
20#include "test_macros.h"
21#include "operator_hijacker.h"
22
23template <class ToIterator, class FromIterator>
24void test() {
25 FromIterator from;
26 ToIterator copy(from);
27 copy = from;
28
29 ToIterator move(std::move(from));
30 from = FromIterator();
31 move = std::move(from);
32}
33
34void test() {
35 {
36 using I = std::unordered_map<operator_hijacker, operator_hijacker>::iterator;
37 using CI = std::unordered_map<operator_hijacker, operator_hijacker>::const_iterator;
38 test<I, I>();
39 test<CI, I>();
40 test<CI, CI>();
41 }
42 {
43 using IL = std::unordered_map<operator_hijacker, operator_hijacker>::local_iterator;
44 using CIL = std::unordered_map<operator_hijacker, operator_hijacker>::const_local_iterator;
45 test<IL, IL>();
46 test<CIL, IL>();
47 test<CIL, CIL>();
48 }
49}
50

source code of libcxx/test/std/containers/unord/unord.map/iterator.operators.addressof.compile.pass.cpp