]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
os/signal/internal/pty: build on Solaris
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / cxx11.cc
CommitLineData
52066eae
JW
1// { dg-do run { target c++11 } }
2// { dg-options "-g -O0" }
ac4664f9 3// { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } }
8dfb08ab 4
85ec4feb 5// Copyright (C) 2011-2018 Free Software Foundation, Inc.
8dfb08ab
JW
6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 3, or (at your option)
11// any later version.
12
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License along
19// with this library; see the file COPYING3. If not see
20// <http://www.gnu.org/licenses/>.
21
22#include <forward_list>
23#include <unordered_map>
24#include <unordered_set>
25#include <string>
d6222d4e 26#include <memory>
8dfb08ab
JW
27#include <iostream>
28
c77efe8f
PM
29typedef std::tuple<int, int> ExTuple;
30
8dfb08ab
JW
31template<class T>
32void
33placeholder(const T &s)
34{
35 std::cout << s;
36}
37
38template<class T, class S>
39void
40placeholder(const std::pair<T,S> &s)
41{
42 std::cout << s.first;
43}
44
45template<class T>
46void
47use(const T &container)
48{
49 for (typename T::const_iterator i = container.begin();
50 i != container.end();
51 ++i)
52 placeholder(*i);
53}
54
c4269a63
TT
55struct datum
56{
57 std::string s;
58 int i;
59};
60
61std::unique_ptr<datum> global;
62
8dfb08ab
JW
63int
64main()
65{
66 std::forward_list<int> efl;
67// { dg-final { note-test efl "empty std::forward_list" } }
68
c77efe8f
PM
69 std::forward_list<int> &refl = efl;
70// { dg-final { note-test refl "empty std::forward_list" } }
71
8dfb08ab
JW
72 std::forward_list<int> fl;
73 fl.push_front(2);
74 fl.push_front(1);
75// { dg-final { note-test fl {std::forward_list = {[0] = 1, [1] = 2}} } }
76
c77efe8f
PM
77 std::forward_list<int> &rfl = fl;
78// { dg-final { note-test rfl {std::forward_list = {[0] = 1, [1] = 2}} } }
79
8dfb08ab
JW
80 std::unordered_map<int, std::string> eum;
81// { dg-final { note-test eum "std::unordered_map with 0 elements" } }
c77efe8f
PM
82 std::unordered_map<int, std::string> &reum = eum;
83// { dg-final { note-test reum "std::unordered_map with 0 elements" } }
84
8dfb08ab
JW
85 std::unordered_multimap<int, std::string> eumm;
86// { dg-final { note-test eumm "std::unordered_multimap with 0 elements" } }
c77efe8f
PM
87 std::unordered_multimap<int, std::string> &reumm = eumm;
88// { dg-final { note-test reumm "std::unordered_multimap with 0 elements" } }
89
8dfb08ab
JW
90 std::unordered_set<int> eus;
91// { dg-final { note-test eus "std::unordered_set with 0 elements" } }
c77efe8f
PM
92 std::unordered_set<int> &reus = eus;
93// { dg-final { note-test reus "std::unordered_set with 0 elements" } }
94
8dfb08ab
JW
95 std::unordered_multiset<int> eums;
96// { dg-final { note-test eums "std::unordered_multiset with 0 elements" } }
c77efe8f
PM
97 std::unordered_multiset<int> &reums = eums;
98// { dg-final { note-test reums "std::unordered_multiset with 0 elements" } }
8dfb08ab 99
d25b1e3a
TT
100 std::unordered_map<int, std::string> uom;
101 uom[5] = "three";
102 uom[3] = "seven";
103// { dg-final { note-test uom {std::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } }
104
c77efe8f
PM
105 std::unordered_map<int, std::string> &ruom = uom;
106// { dg-final { note-test ruom {std::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } }
107
d25b1e3a
TT
108 std::unordered_multimap<int, std::string> uomm;
109 uomm.insert(std::pair<int, std::string> (5, "three"));
110 uomm.insert(std::pair<int, std::string> (5, "seven"));
111// { dg-final { note-test uomm {std::unordered_multimap with 2 elements = {[5] = "seven", [5] = "three"}} } }
c77efe8f
PM
112 std::unordered_multimap<int, std::string> &ruomm = uomm;
113// { dg-final { note-test ruomm {std::unordered_multimap with 2 elements = {[5] = "seven", [5] = "three"}} } }
d25b1e3a
TT
114
115 std::unordered_set<int> uos;
116 uos.insert(5);
d33c00e1 117// { dg-final { note-test uos {std::unordered_set with 1 element = {[0] = 5}} } }
c77efe8f 118 std::unordered_set<int> &ruos = uos;
d33c00e1 119// { dg-final { note-test ruos {std::unordered_set with 1 element = {[0] = 5}} } }
d25b1e3a
TT
120
121 std::unordered_multiset<int> uoms;
122 uoms.insert(5);
d33c00e1 123// { dg-final { note-test uoms {std::unordered_multiset with 1 element = {[0] = 5}} } }
c77efe8f 124 std::unordered_multiset<int> &ruoms = uoms;
d33c00e1 125// { dg-final { note-test ruoms {std::unordered_multiset with 1 element = {[0] = 5}} } }
d25b1e3a 126
c4269a63
TT
127 std::unique_ptr<datum> uptr (new datum);
128 uptr->s = "hi bob";
129 uptr->i = 23;
d2dfcf82 130// { dg-final { regexp-test uptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } }
c77efe8f 131 std::unique_ptr<datum> &ruptr = uptr;
d2dfcf82 132// { dg-final { regexp-test ruptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } }
c4269a63 133
c77efe8f 134 ExTuple tpl(6,7);
d2dfcf82 135// { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } }
c77efe8f 136 ExTuple &rtpl = tpl;
d2dfcf82 137// { dg-final { note-test rtpl {std::tuple containing = {[1] = 6, [2] = 7}} } }
8dfb08ab
JW
138 placeholder(""); // Mark SPOT
139 use(efl);
140 use(fl);
141 use(eum);
142 use(eumm);
143 use(eus);
144 use(eums);
c4269a63
TT
145 use(uoms);
146 use(uptr->s);
8dfb08ab 147
af583c44 148 std::cout << "\n";
8dfb08ab
JW
149 return 0;
150}
151
152// { dg-final { gdb-test SPOT } }