]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / libfundts.cc
1 // { dg-do run { target c++14 } }
2 // { dg-options "-g -O0" }
3 // { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } }
4
5 // Copyright (C) 2014-2019 Free Software Foundation, Inc.
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 // Type printers only recognize the old std::string for now.
23 #define _GLIBCXX_USE_CXX11_ABI 0
24
25 #include <experimental/any>
26 #include <experimental/optional>
27 #include <experimental/string_view>
28 #include <string>
29 #include <map>
30 #include <iostream>
31
32 using std::experimental::any;
33 using std::experimental::optional;
34 using std::experimental::string_view;
35
36 int
37 main()
38 {
39 string_view str = "string";
40 // { dg-final { note-test str "\"string\"" } }
41
42 optional<int> o;
43 // { dg-final { note-test o {std::experimental::optional<int> [no contained value]} } }
44 optional<bool> ob{false};
45 // { dg-final { note-test ob {std::experimental::optional<bool> = {[contained value] = false}} } }
46 optional<int> oi{5};
47 // { dg-final { note-test oi {std::experimental::optional<int> = {[contained value] = 5}} } }
48 optional<void*> op{nullptr};
49 // { dg-final { note-test op {std::experimental::optional<void *> = {[contained value] = 0x0}} } }
50 optional<std::map<int, double>> om;
51 om = std::map<int, double>{ {1, 2.}, {3, 4.}, {5, 6.} };
52 // { dg-final { note-test om {std::experimental::optional<std::map<int, double>> containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
53 optional<std::string> os{ "stringy" };
54 // { dg-final { note-test os {std::experimental::optional<std::string> = {[contained value] = "stringy"}} } }
55
56 any a;
57 // { dg-final { note-test a {std::experimental::any [no contained value]} } }
58 any ab(false);
59 // { dg-final { note-test ab {std::experimental::any containing bool = {[contained value] = false}} } }
60 any ai(6);
61 // { dg-final { note-test ai {std::experimental::any containing int = {[contained value] = 6}} } }
62 any ap = (void*)nullptr;
63 // { dg-final { note-test ap {std::experimental::any containing void * = {[contained value] = 0x0}} } }
64 any as = *os;
65 // { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} } }
66 any as2("stringiest");
67 // { dg-final { regexp-test as2 {std::experimental::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
68 any am = *om;
69 // { dg-final { note-test am {std::experimental::any containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
70
71 std::cout << "\n";
72 return 0; // Mark SPOT
73 }
74
75 // { dg-final { gdb-test SPOT } }