simple.cc: New file.
[gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / simple.cc
1 // { dg-do run }
2 // { dg-options "-g" }
3
4 // Copyright (C) 2011 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 <string>
22 #include <deque>
23 #include <bitset>
24 #include <iostream>
25 #include <list>
26 #include <map>
27
28 template<class T>
29 void
30 placeholder(const T &s)
31 {
32 std::cout << s;
33 }
34
35 template<class T, class S>
36 void
37 placeholder(const std::pair<T,S> &s)
38 {
39 std::cout << s.first;
40 }
41
42 template<class T>
43 void
44 use(const T &container)
45 {
46 for (typename T::const_iterator i = container.begin();
47 i != container.end();
48 ++i)
49 placeholder(*i);
50 }
51
52 int
53 main()
54 {
55 std::string str = "zardoz";
56 // { dg-final { note-test str "\"zardoz\"" } }
57
58 std::bitset<10> bs;
59 bs[0] = 1;
60 bs[5] = 1;
61 bs[7] = 1;
62 // { dg-final { note-test bs {std::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
63
64 std::deque<std::string> deq;
65 deq.push_back("one");
66 deq.push_back("two");
67 // { dg-final { note-test deq {std::deque with 2 elements = {"one", "two"}} } }
68
69 std::list<std::string> lst;
70 lst.push_back("one");
71 lst.push_back("two");
72 // { dg-final { note-test lst {std::list = {[0] = "one", [1] = "two"}} } }
73
74 std::map<std::string, int> mp;
75 mp["zardoz"] = 23;
76 // { dg-final { note-test mp {std::map with 1 elements = {["zardoz"] = 23}} } }
77
78 placeholder(str); // Mark SPOT
79 std::cout << bs;
80 use(deq);
81 use(lst);
82 use(mp);
83
84 return 0;
85 }
86
87 // { dg-final { gdb-test SPOT } }