1// { dg-do run }
2// { dg-options "-std=gnu++11 -g -O0" }
3
4// Copyright (C) 2011-2015 Free Software Foundation, Inc.
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>
25#include <memory>
26#include <iostream>
27
28typedef std::tuple<int, int> ExTuple;
29
30template<class T>
31void
32placeholder(const T &s)
33{
34  std::cout << s;
35}
36
37template<class T, class S>
38void
39placeholder(const std::pair<T,S> &s)
40{
41  std::cout << s.first;
42}
43
44template<class T>
45void
46use(const T &container)
47{
48  for (typename T::const_iterator i = container.begin();
49       i != container.end();
50       ++i)
51    placeholder(*i);
52}
53
54struct datum
55{
56  std::string s;
57  int i;
58};
59
60std::unique_ptr<datum> global;
61
62int
63main()
64{
65  std::forward_list<int> efl;
66// { dg-final { note-test efl "empty std::forward_list" } }
67
68  std::forward_list<int> &refl = efl;
69// { dg-final { note-test refl "empty std::forward_list" } }
70
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
76  std::forward_list<int> &rfl = fl;
77// { dg-final { note-test rfl {std::forward_list = {[0] = 1, [1] = 2}} } }
78
79  std::unordered_map<int, std::string> eum;
80// { dg-final { note-test eum "std::unordered_map with 0 elements" } }
81  std::unordered_map<int, std::string> &reum = eum;
82// { dg-final { note-test reum "std::unordered_map with 0 elements" } }
83
84  std::unordered_multimap<int, std::string> eumm;
85// { dg-final { note-test eumm "std::unordered_multimap with 0 elements" } }
86  std::unordered_multimap<int, std::string> &reumm = eumm;
87// { dg-final { note-test reumm "std::unordered_multimap with 0 elements" } }
88
89  std::unordered_set<int> eus;
90// { dg-final { note-test eus "std::unordered_set with 0 elements" } }
91  std::unordered_set<int> &reus = eus;
92// { dg-final { note-test reus "std::unordered_set with 0 elements" } }
93
94  std::unordered_multiset<int> eums;
95// { dg-final { note-test eums "std::unordered_multiset with 0 elements" } }
96  std::unordered_multiset<int> &reums = eums;
97// { dg-final { note-test reums "std::unordered_multiset with 0 elements" } }
98
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
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
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"}} } }
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"}} } }
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}} } }
117  std::unordered_set<int> &ruos = uos;
118// { dg-final { note-test ruos {std::unordered_set with 1 elements = {[0] = 5}} } }
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}} } }
123  std::unordered_multiset<int> &ruoms = uoms;
124// { dg-final { note-test ruoms {std::unordered_multiset with 1 elements = {[0] = 5}} } }
125
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.*} } }
130  std::unique_ptr<datum> &ruptr = uptr;
131// { dg-final { regexp-test ruptr {std::unique_ptr.datum. containing 0x.*} } }
132
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}} } }
137  placeholder(""); // Mark SPOT
138  use(efl);
139  use(fl);
140  use(eum);
141  use(eumm);
142  use(eus);
143  use(eums);
144  use(uoms);
145  use(uptr->s);
146
147  return 0;
148}
149
150// { dg-final { gdb-test SPOT } }
151