]>
Commit | Line | Data |
---|---|---|
d1462b07 | 1 | // { dg-do compile { target c++17 } } |
52e86221 | 2 | |
83ffe9cd | 3 | // Copyright (C) 2014-2023 Free Software Foundation, Inc. |
52e86221 VV |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 3, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING3. If not see | |
18 | // <http://www.gnu.org/licenses/>. | |
19 | ||
20 | #include <any> | |
21 | ||
23c3a059 VV |
22 | using std::any; |
23 | using std::any_cast; | |
24 | ||
52e86221 VV |
25 | void test01() |
26 | { | |
52e86221 | 27 | const any y(1); |
d1462b07 JW |
28 | any_cast<int&>(y); // { dg-error "here" } |
29 | // { dg-error "Template argument must be constructible from a const value" "" { target { *-*-* } } 0 } | |
23c3a059 VV |
30 | } |
31 | ||
32 | void test02() | |
33 | { | |
34 | any y(1); | |
d1462b07 JW |
35 | any_cast<int&&>(y); // { dg-error "here" } |
36 | // { dg-error "Template argument must be constructible from an lvalue" "" { target { *-*-* } } 0 } | |
23c3a059 VV |
37 | } |
38 | ||
39 | void test03() | |
40 | { | |
41 | any y(1); | |
d1462b07 JW |
42 | any_cast<int&>(std::move(y)); // { dg-error "here" } |
43 | // { dg-error "Template argument must be constructible from an rvalue" "" { target { *-*-* } } 0 } | |
52e86221 | 44 | } |
d1462b07 JW |
45 | |
46 | // { dg-prune-output "invalid 'static_cast'" } |