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