Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / associative / map / compare.pass.cpp
blob31221b234af5e3f17ae142a4d01b32afdbf9793b
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 // <map>
11 // template <class Key, class T, class Compare = less<Key>,
12 // class Allocator = allocator<pair<const Key, T>>>
13 // class map
15 // https://llvm.org/PR16538
16 // https://llvm.org/PR16549
18 #include <map>
19 #include <utility>
20 #include <cassert>
22 #include "test_macros.h"
24 struct Key {
25 template <typename T> Key(const T&) {}
26 bool operator< (const Key&) const { return false; }
29 int main(int, char**)
31 typedef std::map<Key, int> MapT;
32 typedef MapT::iterator Iter;
33 typedef std::pair<Iter, bool> IterBool;
35 MapT m_empty;
36 MapT m_contains;
37 m_contains[Key(0)] = 42;
39 Iter it = m_empty.find(Key(0));
40 assert(it == m_empty.end());
41 it = m_contains.find(Key(0));
42 assert(it != m_contains.end());
45 MapT map;
46 IterBool result = map.insert(std::make_pair(Key(0), 42));
47 assert(result.second);
48 assert(result.first->second == 42);
49 IterBool result2 = map.insert(std::make_pair(Key(0), 43));
50 assert(!result2.second);
51 assert(map[Key(0)] == 42);
54 return 0;