]>
Commit | Line | Data |
---|---|---|
8dfb08ab | 1 | // { dg-do run } |
c77efe8f | 2 | // { dg-options "-std=gnu++11 -g -O0" } |
8dfb08ab | 3 | |
aa118a03 | 4 | // Copyright (C) 2011-2014 Free Software Foundation, Inc. |
8dfb08ab JW |
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 <forward_list> | |
22 | #include <unordered_map> | |
23 | #include <unordered_set> | |
24 | #include <string> | |
d6222d4e | 25 | #include <memory> |
8dfb08ab JW |
26 | #include <iostream> |
27 | ||
c77efe8f PM |
28 | typedef std::tuple<int, int> ExTuple; |
29 | ||
8dfb08ab JW |
30 | template<class T> |
31 | void | |
32 | placeholder(const T &s) | |
33 | { | |
34 | std::cout << s; | |
35 | } | |
36 | ||
37 | template<class T, class S> | |
38 | void | |
39 | placeholder(const std::pair<T,S> &s) | |
40 | { | |
41 | std::cout << s.first; | |
42 | } | |
43 | ||
44 | template<class T> | |
45 | void | |
46 | use(const T &container) | |
47 | { | |
48 | for (typename T::const_iterator i = container.begin(); | |
49 | i != container.end(); | |
50 | ++i) | |
51 | placeholder(*i); | |
52 | } | |
53 | ||
c4269a63 TT |
54 | struct datum |
55 | { | |
56 | std::string s; | |
57 | int i; | |
58 | }; | |
59 | ||
60 | std::unique_ptr<datum> global; | |
61 | ||
8dfb08ab JW |
62 | int |
63 | main() | |
64 | { | |
65 | std::forward_list<int> efl; | |
66 | // { dg-final { note-test efl "empty std::forward_list" } } | |
67 | ||
c77efe8f PM |
68 | std::forward_list<int> &refl = efl; |
69 | // { dg-final { note-test refl "empty std::forward_list" } } | |
70 | ||
8dfb08ab JW |
71 | std::forward_list<int> fl; |
72 | fl.push_front(2); | |
73 | fl.push_front(1); | |
74 | // { dg-final { note-test fl {std::forward_list = {[0] = 1, [1] = 2}} } } | |
75 | ||
c77efe8f PM |
76 | std::forward_list<int> &rfl = fl; |
77 | // { dg-final { note-test rfl {std::forward_list = {[0] = 1, [1] = 2}} } } | |
78 | ||
8dfb08ab JW |
79 | std::unordered_map<int, std::string> eum; |
80 | // { dg-final { note-test eum "std::unordered_map with 0 elements" } } | |
c77efe8f PM |
81 | std::unordered_map<int, std::string> &reum = eum; |
82 | // { dg-final { note-test reum "std::unordered_map with 0 elements" } } | |
83 | ||
8dfb08ab JW |
84 | std::unordered_multimap<int, std::string> eumm; |
85 | // { dg-final { note-test eumm "std::unordered_multimap with 0 elements" } } | |
c77efe8f PM |
86 | std::unordered_multimap<int, std::string> &reumm = eumm; |
87 | // { dg-final { note-test reumm "std::unordered_multimap with 0 elements" } } | |
88 | ||
8dfb08ab JW |
89 | std::unordered_set<int> eus; |
90 | // { dg-final { note-test eus "std::unordered_set with 0 elements" } } | |
c77efe8f PM |
91 | std::unordered_set<int> &reus = eus; |
92 | // { dg-final { note-test reus "std::unordered_set with 0 elements" } } | |
93 | ||
8dfb08ab JW |
94 | std::unordered_multiset<int> eums; |
95 | // { dg-final { note-test eums "std::unordered_multiset with 0 elements" } } | |
c77efe8f PM |
96 | std::unordered_multiset<int> &reums = eums; |
97 | // { dg-final { note-test reums "std::unordered_multiset with 0 elements" } } | |
8dfb08ab | 98 | |
d25b1e3a TT |
99 | std::unordered_map<int, std::string> uom; |
100 | uom[5] = "three"; | |
101 | uom[3] = "seven"; | |
102 | // { dg-final { note-test uom {std::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } } | |
103 | ||
c77efe8f PM |
104 | std::unordered_map<int, std::string> &ruom = uom; |
105 | // { dg-final { note-test ruom {std::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } } | |
106 | ||
d25b1e3a TT |
107 | std::unordered_multimap<int, std::string> uomm; |
108 | uomm.insert(std::pair<int, std::string> (5, "three")); | |
109 | uomm.insert(std::pair<int, std::string> (5, "seven")); | |
110 | // { dg-final { note-test uomm {std::unordered_multimap with 2 elements = {[5] = "seven", [5] = "three"}} } } | |
c77efe8f PM |
111 | std::unordered_multimap<int, std::string> &ruomm = uomm; |
112 | // { dg-final { note-test ruomm {std::unordered_multimap with 2 elements = {[5] = "seven", [5] = "three"}} } } | |
d25b1e3a TT |
113 | |
114 | std::unordered_set<int> uos; | |
115 | uos.insert(5); | |
116 | // { dg-final { note-test uos {std::unordered_set with 1 elements = {[0] = 5}} } } | |
c77efe8f PM |
117 | std::unordered_set<int> &ruos = uos; |
118 | // { dg-final { note-test ruos {std::unordered_set with 1 elements = {[0] = 5}} } } | |
d25b1e3a TT |
119 | |
120 | std::unordered_multiset<int> uoms; | |
121 | uoms.insert(5); | |
122 | // { dg-final { note-test uoms {std::unordered_multiset with 1 elements = {[0] = 5}} } } | |
c77efe8f PM |
123 | std::unordered_multiset<int> &ruoms = uoms; |
124 | // { dg-final { note-test ruoms {std::unordered_multiset with 1 elements = {[0] = 5}} } } | |
d25b1e3a | 125 | |
c4269a63 TT |
126 | std::unique_ptr<datum> uptr (new datum); |
127 | uptr->s = "hi bob"; | |
128 | uptr->i = 23; | |
129 | // { dg-final { regexp-test uptr {std::unique_ptr.datum. containing 0x.*} } } | |
c77efe8f PM |
130 | std::unique_ptr<datum> &ruptr = uptr; |
131 | // { dg-final { regexp-test ruptr {std::unique_ptr.datum. containing 0x.*} } } | |
c4269a63 | 132 | |
c77efe8f PM |
133 | ExTuple tpl(6,7); |
134 | // { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } } | |
135 | ExTuple &rtpl = tpl; | |
136 | // { dg-final { note-test rtpl {std::tuple containing = {[1] = 6, [2] = 7}} } } | |
8dfb08ab JW |
137 | placeholder(""); // Mark SPOT |
138 | use(efl); | |
139 | use(fl); | |
140 | use(eum); | |
141 | use(eumm); | |
142 | use(eus); | |
143 | use(eums); | |
c4269a63 TT |
144 | use(uoms); |
145 | use(uptr->s); | |
8dfb08ab JW |
146 | |
147 | return 0; | |
148 | } | |
149 | ||
150 | // { dg-final { gdb-test SPOT } } |