1 // { dg-options "-g -O0 -std=gnu++1z" }
2 // { dg-do run { target c++1z } }
4 // Copyright (C) 2014-2016 Free Software Foundation, Inc.
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)
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 // Type printers only recognize the old std::string for now.
22 #define _GLIBCXX_USE_CXX11_ABI 0
27 #include <string_view>
30 #include <unordered_set>
36 using std::string_view
;
38 using std::unordered_set
;
43 string_view str
= "string";
44 // { dg-final { note-test str "\"string\"" } }
47 // { dg-final { note-test o {std::optional<int> [no contained value]} } }
48 optional
<bool> ob
{false};
49 // { dg-final { note-test ob {std::optional<bool> = {[contained value] = false}} } }
51 // { dg-final { note-test oi {std::optional<int> = {[contained value] = 5}} } }
52 optional
<void*> op
{nullptr};
53 // { dg-final { note-test op {std::optional<void *> = {[contained value] = 0x0}} } }
54 optional
<std::map
<int, double>> om
;
55 om
= std::map
<int, double>{ {1, 2.}, {3, 4.}, {5, 6.} };
56 // { dg-final { note-test om {std::optional<std::map<int, double>> containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
57 optional
<std::string
> os
{ "stringy" };
58 // { dg-final { note-test os {std::optional<std::string> = {[contained value] = "stringy"}} } }
61 // { dg-final { note-test a {std::any [no contained value]} } }
63 // { dg-final { note-test ab {std::any containing bool = {[contained value] = false}} } }
65 // { dg-final { note-test ai {std::any containing int = {[contained value] = 6}} } }
66 any ap
= (void*)nullptr;
67 // { dg-final { note-test ap {std::any containing void * = {[contained value] = 0x0}} } }
69 // { dg-final { note-test as {std::any containing std::string = {[contained value] = "stringy"}} } }
70 any
as2("stringiest");
71 // { dg-final { regexp-test as2 {std::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
73 // { dg-final { note-test am {std::any containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
75 struct S
{ operator int() { throw 42; }};
76 variant
<float, int, string_view
> v0
;
77 // { dg-final { note-test v0 {std::variant<float, int, std::string_view> [index 0] = {0}} } }
78 variant
<float, int, string_view
> v1
{ 0.5f
};
79 // { dg-final { note-test v1 {std::variant<float, int, std::string_view> [index 0] = {0.5}} } }
80 variant
<float, int, string_view
> v2
;
84 // { dg-final { note-test v2 {std::variant<float, int, std::string_view> [no contained value]} } }
85 variant
<float, int, string_view
> v3
{ 3 };
86 // { dg-final { note-test v3 {std::variant<float, int, std::string_view> [index 1] = {3}} } }
87 variant
<float, int, string_view
> v4
{ str
};
88 // { dg-final { note-test v4 {std::variant<float, int, std::string_view> [index 2] = {"string"}} } }
89 variant
<string_view
&> vref
{str
};
90 // { dg-final { note-test vref {std::variant<std::basic_string_view<char, std::char_traits<char> > &> [index 0] = {"string"}} } }
92 map
<int, string_view
> m
{ {1, "one"} };
93 map
<int, string_view
>::node_type n0
;
94 // { dg-final { note-test n0 {empty node handle for map}}}
95 map
<int, string_view
>::node_type n1
= m
.extract(1);
96 // { dg-final { note-test n1 {node handle for map with element = {{first = 1, second = "two"}}}}}
98 unordered_set
<int> s
{ 3, 4 };
99 unordered_set
<int>::node_type n2
;
100 // { dg-final { note-test n2 {empty node handle for unordered set}}}
101 unordered_set
<int>::node_type n3
= s
.extract(3);
102 // { dg-final { note-test n1 {node handle for unordered set with element = {3}}}}
105 return 0; // Mark SPOT
108 // { dg-final { gdb-test SPOT } }