2013-05-15 François Dumont <fdumont@gcc.gnu.org>
[official-gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / tr1.cc
blob3fac36edd3cdb891d9de87f478373cc0fd2b1b6a
1 // { dg-do run }
2 // { dg-options "-g" }
4 // Copyright (C) 2013 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.
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.
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/>.
21 #include <tr1/unordered_map>
22 #include <tr1/unordered_set>
23 #include <string>
24 #include <iostream>
26 template<class T>
27 void
28 placeholder(const T &s)
30 std::cout << s;
33 template<class T, class S>
34 void
35 placeholder(const std::pair<T,S> &s)
37 std::cout << s.first;
40 template<class T>
41 void
42 use(const T &container)
44 for (typename T::const_iterator i = container.begin();
45 i != container.end();
46 ++i)
47 placeholder(*i);
50 int
51 main()
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" } }
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"}} } }
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"}} } }
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}} } }
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}} } }
80 placeholder(""); // Mark SPOT
81 use(eum);
82 use(eumm);
83 use(eus);
84 use(eums);
85 use(uoms);
87 return 0;
90 // { dg-final { gdb-test SPOT } }