1 // { dg-options "-g -O0 -std=gnu++1z" }
2 // { dg-do run { target c++1z } }
3 // { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } }
5 // Copyright (C) 2014-2017 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>
37 using std::string_view
;
39 using std::unordered_set
;
44 string_view str
= "string";
45 // { dg-final { note-test str "\"string\"" } }
48 // { dg-final { note-test o {std::optional<int> [no contained value]} } }
49 optional
<bool> ob
{false};
50 // { dg-final { note-test ob {std::optional<bool> = {[contained value] = false}} } }
52 // { dg-final { note-test oi {std::optional<int> = {[contained value] = 5}} } }
53 optional
<void*> op
{nullptr};
54 // { dg-final { note-test op {std::optional<void *> = {[contained value] = 0x0}} } }
55 optional
<std::map
<int, double>> om
;
56 om
= std::map
<int, double>{ {1, 2.}, {3, 4.}, {5, 6.} };
57 // { dg-final { note-test om {std::optional<std::map<int, double>> containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
58 optional
<std::string
> os
{ "stringy" };
59 // { dg-final { note-test os {std::optional<std::string> = {[contained value] = "stringy"}} } }
62 // { dg-final { note-test a {std::any [no contained value]} } }
64 // { dg-final { note-test ab {std::any containing bool = {[contained value] = false}} } }
66 // { dg-final { note-test ai {std::any containing int = {[contained value] = 6}} } }
67 any ap
= (void*)nullptr;
68 // { dg-final { note-test ap {std::any containing void * = {[contained value] = 0x0}} } }
70 // { dg-final { note-test as {std::any containing std::string = {[contained value] = "stringy"}} } }
71 any
as2("stringiest");
72 // { dg-final { regexp-test as2 {std::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
74 // { dg-final { note-test am {std::any containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
76 struct S
{ operator int() { throw 42; }};
77 variant
<float, int, string_view
> v0
;
78 // { dg-final { note-test v0 {std::variant<float, int, std::string_view> [index 0] = {0}} } }
79 variant
<float, int, string_view
> v1
{ 0.5f
};
80 // { dg-final { note-test v1 {std::variant<float, int, std::string_view> [index 0] = {0.5}} } }
81 variant
<float, int, string_view
> v2
;
85 // { dg-final { note-test v2 {std::variant<float, int, std::string_view> [no contained value]} } }
86 variant
<float, int, string_view
> v3
{ 3 };
87 // { dg-final { note-test v3 {std::variant<float, int, std::string_view> [index 1] = {3}} } }
88 variant
<float, int, string_view
> v4
{ str
};
89 // { dg-final { note-test v4 {std::variant<float, int, std::string_view> [index 2] = {"string"}} } }
91 map
<int, string_view
> m
{ {1, "one"} };
92 map
<int, string_view
>::node_type n0
;
93 // { dg-final { note-test n0 {empty node handle for map}}}
94 map
<int, string_view
>::node_type n1
= m
.extract(1);
95 // { dg-final { note-test n1 {node handle for map with element = {{first = 1, second = "two"}}}}}
97 unordered_set
<int> s
{ 3, 4 };
98 unordered_set
<int>::node_type n2
;
99 // { dg-final { note-test n2 {empty node handle for unordered set}}}
100 unordered_set
<int>::node_type n3
= s
.extract(3);
101 // { dg-final { note-test n1 {node handle for unordered set with element = {3}}}}
104 return 0; // Mark SPOT
107 // { dg-final { gdb-test SPOT } }