]>
Commit | Line | Data |
---|---|---|
4722d005 FD |
1 | // { dg-do run } |
2 | // { dg-options "-g" } | |
3 | ||
818ab71a | 4 | // Copyright (C) 2013-2016 Free Software Foundation, Inc. |
4722d005 FD |
5 | // |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
9 | // Free Software Foundation; either version 3, or (at your option) | |
10 | // any later version. | |
11 | ||
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | ||
17 | // You should have received a copy of the GNU General Public License along | |
18 | // with this library; see the file COPYING3. If not see | |
19 | // <http://www.gnu.org/licenses/>. | |
20 | ||
21 | #include <tr1/unordered_map> | |
22 | #include <tr1/unordered_set> | |
23 | #include <string> | |
24 | #include <iostream> | |
25 | ||
26 | template<class T> | |
27 | void | |
28 | placeholder(const T &s) | |
29 | { | |
30 | std::cout << s; | |
31 | } | |
32 | ||
33 | template<class T, class S> | |
34 | void | |
35 | placeholder(const std::pair<T,S> &s) | |
36 | { | |
37 | std::cout << s.first; | |
38 | } | |
39 | ||
40 | template<class T> | |
41 | void | |
42 | use(const T &container) | |
43 | { | |
44 | for (typename T::const_iterator i = container.begin(); | |
45 | i != container.end(); | |
46 | ++i) | |
47 | placeholder(*i); | |
48 | } | |
49 | ||
50 | int | |
51 | main() | |
52 | { | |
53 | std::tr1::unordered_map<int, std::string> eum; | |
54 | // { dg-final { note-test eum "std::tr1::unordered_map with 0 elements" } } | |
55 | std::tr1::unordered_multimap<int, std::string> eumm; | |
56 | // { dg-final { note-test eumm "std::tr1::unordered_multimap with 0 elements" } } | |
57 | std::tr1::unordered_set<int> eus; | |
58 | // { dg-final { note-test eus "std::tr1::unordered_set with 0 elements" } } | |
59 | std::tr1::unordered_multiset<int> eums; | |
60 | // { dg-final { note-test eums "std::tr1::unordered_multiset with 0 elements" } } | |
61 | ||
62 | std::tr1::unordered_map<int, std::string> uom; | |
63 | uom[5] = "three"; | |
64 | uom[3] = "seven"; | |
65 | // { dg-final { note-test uom {std::tr1::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } } | |
66 | ||
67 | std::tr1::unordered_multimap<int, std::string> uomm; | |
68 | uomm.insert(std::pair<int, std::string> (5, "three")); | |
69 | uomm.insert(std::pair<int, std::string> (5, "seven")); | |
70 | // { dg-final { note-test uomm {std::tr1::unordered_multimap with 2 elements = {[5] = "three", [5] = "seven"}} } } | |
71 | ||
72 | std::tr1::unordered_set<int> uos; | |
73 | uos.insert(5); | |
74 | // { dg-final { note-test uos {std::tr1::unordered_set with 1 elements = {[0] = 5}} } } | |
75 | ||
76 | std::tr1::unordered_multiset<int> uoms; | |
77 | uoms.insert(5); | |
78 | // { dg-final { note-test uoms {std::tr1::unordered_multiset with 1 elements = {[0] = 5}} } } | |
79 | ||
80 | placeholder(""); // Mark SPOT | |
81 | use(eum); | |
82 | use(eumm); | |
83 | use(eus); | |
84 | use(eums); | |
85 | use(uoms); | |
86 | ||
af583c44 | 87 | std::cout << "\n"; |
4722d005 FD |
88 | return 0; |
89 | } | |
90 | ||
91 | // { dg-final { gdb-test SPOT } } |