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 // <map> 10 11 // template <class Key, class T, class Compare = less<Key>, 12 // class Allocator = allocator<pair<const Key, T>>> 13 // class map 14 15 // https://bugs.llvm.org/show_bug.cgi?id=16538 16 // https://bugs.llvm.org/show_bug.cgi?id=16549 17 18 #include <map> 19 #include <utility> 20 #include <cassert> 21 22 struct Key { 23 template <typename T> Key(const T&) {} 24 bool operator< (const Key&) const { return false; } 25 }; 26 27 int main(int, char**) 28 { 29 typedef std::map<Key, int> MapT; 30 typedef MapT::iterator Iter; 31 typedef std::pair<Iter, bool> IterBool; 32 { 33 MapT m_empty; 34 MapT m_contains; 35 m_contains[Key(0)] = 42; 36 37 Iter it = m_empty.find(Key(0)); 38 assert(it == m_empty.end()); 39 it = m_contains.find(Key(0)); 40 assert(it != m_contains.end()); 41 } 42 { 43 MapT map; 44 IterBool result = map.insert(std::make_pair(Key(0), 42)); 45 assert(result.second); 46 assert(result.first->second == 42); 47 IterBool result2 = map.insert(std::make_pair(Key(0), 43)); 48 assert(!result2.second); 49 assert(map[Key(0)] == 42); 50 } 51 52 return 0; 53 } 54