1 // { dg-options "-g -O0 -std=gnu++17" }
2 // { dg-do run { target c++17 } }
3 // { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } }
5 // Copyright (C) 2014-2018 Free Software Foundation, Inc.
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)
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.
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/>.
22 // Type printers only recognize the old std::string for now.
23 #define _GLIBCXX_USE_CXX11_ABI 0
28 #include <string_view>
31 #include <unordered_set>
38 using std::string_view
;
40 using std::unordered_set
;
41 using std::shared_ptr
;
47 string_view str
= "string";
48 // { dg-final { note-test str "\"string\"" } }
51 // { dg-final { note-test o {std::optional<int> [no contained value]} } }
52 optional
<bool> ob
{false};
53 // { dg-final { note-test ob {std::optional<bool> = {[contained value] = false}} } }
55 // { dg-final { note-test oi {std::optional<int> = {[contained value] = 5}} } }
56 optional
<void*> op
{nullptr};
57 // { dg-final { note-test op {std::optional<void *> = {[contained value] = 0x0}} } }
58 optional
<std::map
<int, double>> om
;
59 om
= std::map
<int, double>{ {1, 2.}, {3, 4.}, {5, 6.} };
60 // { dg-final { note-test om {std::optional<std::map<int, double>> containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
61 optional
<std::string
> os
{ "stringy" };
62 // { dg-final { note-test os {std::optional<std::string> = {[contained value] = "stringy"}} } }
65 // { dg-final { note-test a {std::any [no contained value]} } }
67 // { dg-final { note-test ab {std::any containing bool = {[contained value] = false}} } }
69 // { dg-final { note-test ai {std::any containing int = {[contained value] = 6}} } }
70 any ap
= (void*)nullptr;
71 // { dg-final { note-test ap {std::any containing void * = {[contained value] = 0x0}} } }
73 // { dg-final { note-test as {std::any containing std::string = {[contained value] = "stringy"}} } }
74 any
as2("stringiest");
75 // { dg-final { regexp-test as2 {std::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
77 // { dg-final { note-test am {std::any containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
79 struct S
{ operator int() { throw 42; }};
80 variant
<float, int, string_view
> v0
;
81 // { dg-final { note-test v0 {std::variant<float, int, std::string_view> [index 0] = {0}} } }
82 variant
<float, int, string_view
> v1
{ 0.5f
};
83 // { dg-final { note-test v1 {std::variant<float, int, std::string_view> [index 0] = {0.5}} } }
84 variant
<float, int, string_view
> v2
;
88 // { dg-final { note-test v2 {std::variant<float, int, std::string_view> [no contained value]} } }
89 variant
<float, int, string_view
> v3
{ 3 };
90 // { dg-final { note-test v3 {std::variant<float, int, std::string_view> [index 1] = {3}} } }
91 variant
<float, int, string_view
> v4
{ str
};
92 // { dg-final { note-test v4 {std::variant<float, int, std::string_view> [index 2] = {"string"}} } }
94 map
<int, string_view
> m
{ {1, "one"} };
95 map
<int, string_view
>::node_type n0
;
96 // { dg-final { note-test n0 {empty node handle for map}}}
97 map
<int, string_view
>::node_type n1
= m
.extract(1);
98 // { dg-final { note-test n1 {node handle for map with element = {{first = 1, second = "two"}}}}}
100 unordered_set
<int> s
{ 3, 4 };
101 unordered_set
<int>::node_type n2
;
102 // { dg-final { note-test n2 {empty node handle for unordered set}}}
103 unordered_set
<int>::node_type n3
= s
.extract(3);
104 // { dg-final { note-test n1 {node handle for unordered set with element = {3}}}}
106 shared_ptr
<int[]> p(new int[1]);
109 // { dg-final { regexp-test p {std::shared_ptr.int \[\]. \(use count 1, weak count 2\) = {get\(\) = 0x.*}} } }
110 // { dg-final { regexp-test wp {std::weak_ptr.int \[\]. \(use count 1, weak count 2\) = {get\(\) = 0x.*}} } }
112 shared_ptr
<int[2]> q(new int[2]);
115 // { dg-final { regexp-test q {std::shared_ptr.int \[2\]. \(use count 2, weak count 1\) = {get\(\) = 0x.*}} } }
116 // { dg-final { regexp-test wq {std::weak_ptr.int \[2\]. \(use count 2, weak count 1\) = {get\(\) = 0x.*}} } }
119 return 0; // Mark SPOT
122 // { dg-final { gdb-test SPOT } }