1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <map>
11
12// template <class Key, class T, class Compare = less<Key>,
13//           class Allocator = allocator<pair<const Key, T>>>
14// class map
15
16// http://llvm.org/bugs/show_bug.cgi?id=16538
17// http://llvm.org/bugs/show_bug.cgi?id=16549
18
19#include <map>
20#include <utility>
21#include <cassert>
22
23struct Key {
24  template <typename T> Key(const T&) {}
25  bool operator< (const Key&) const { return false; }
26};
27
28int main()
29{
30    typedef std::map<Key, int> MapT;
31    typedef MapT::iterator Iter;
32    typedef std::pair<Iter, bool> IterBool;
33    {
34        MapT m_empty;
35        MapT m_contains;
36        m_contains[Key(0)] = 42;
37
38        Iter it = m_empty.find(Key(0));
39        assert(it == m_empty.end());
40        it = m_contains.find(Key(0));
41        assert(it != m_contains.end());
42    }
43    {
44        MapT map;
45        IterBool result = map.insert(std::make_pair(Key(0), 42));
46        assert(result.second);
47        assert(result.first->second = 42);
48        IterBool result2 = map.insert(std::make_pair(Key(0), 43));
49        assert(!result2.second);
50        assert(map[Key(0)] == 42);
51    }
52}
53