Mercurial > hg > CbC > CbC_gcc
comparison libstdc++-v3/testsuite/20_util/any/cons/92156.cc @ 152:2b5abeee2509
update gcc11
author | anatofuz |
---|---|
date | Mon, 25 May 2020 07:50:57 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
145:1830386684a0 | 152:2b5abeee2509 |
---|---|
1 // { dg-options "-std=gnu++17" } | |
2 // { dg-do run { target c++17 } } | |
3 | |
4 // Copyright (C) 2020 Free Software Foundation, Inc. | |
5 // | |
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) | |
10 // any later version. | |
11 | |
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. | |
16 | |
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/>. | |
20 | |
21 #include <any> | |
22 #include <utility> | |
23 #include <tuple> | |
24 #include <testsuite_hooks.h> | |
25 | |
26 void | |
27 test01() | |
28 { | |
29 auto a = std::any(std::in_place_type<std::any>, 5); | |
30 VERIFY( std::any_cast<int>(std::any_cast<std::any>(a)) == 5 ); | |
31 | |
32 auto b = std::any(std::in_place_type<std::any>, {1}); | |
33 (void) std::any_cast<std::initializer_list<int>>(std::any_cast<std::any>(b)); | |
34 } | |
35 | |
36 void | |
37 test02() | |
38 { | |
39 std::any p = std::pair<std::any, std::any>(1, 1); | |
40 auto pt = std::any_cast<std::pair<std::any, std::any>>(p); | |
41 VERIFY( std::any_cast<int>(pt.first) == 1 ); | |
42 VERIFY( std::any_cast<int>(pt.second) == 1 ); | |
43 | |
44 std::any t = std::tuple<std::any>(1); | |
45 auto tt = std::any_cast<std::tuple<std::any>>(t); | |
46 VERIFY( std::any_cast<int>(std::get<0>(tt)) == 1 ); | |
47 } | |
48 | |
49 int main() | |
50 { | |
51 test01(); | |
52 test02(); | |
53 } |