]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc
1 // { dg-do run { target c++17 } }
2 // { dg-options "-Wno-init-list-lifetime" }
4 // Copyright (C) 2020-2023 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/>.
24 #include <testsuite_hooks.h>
30 a
.emplace
<std::any
>(5);
31 VERIFY( std::any_cast
<int>(std::any_cast
<std::any
>(a
)) == 5 );
34 b
.emplace
<std::any
>({1});
35 (void) std::any_cast
<std::initializer_list
<int>>(std::any_cast
<std::any
>(b
));
42 p
.emplace
<std::pair
<std::any
, std::any
>>(1, 1);
43 auto pt
= std::any_cast
<std::pair
<std::any
, std::any
>>(p
);
44 VERIFY( std::any_cast
<int>(pt
.first
) == 1 );
45 VERIFY( std::any_cast
<int>(pt
.second
) == 1 );
48 t
.emplace
<std::tuple
<std::any
>>(1);
49 auto tt
= std::any_cast
<std::tuple
<std::any
>>(t
);
50 VERIFY( std::any_cast
<int>(std::get
<0>(tt
)) == 1 );