]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/pair/astuple/astuple_cpp14.cc
1 // { dg-do compile { target c++14 } }
3 // Copyright (C) 2015-2024 Free Software Foundation, Inc.
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)
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.
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/>.
21 #include <type_traits>
23 typedef std::pair
<int, long> test_type
;
25 template<std::size_t N
, typename T
>
26 using Tuple_elt
= std::tuple_element_t
<N
, T
>;
30 static_assert( is_same
<Tuple_elt
<0, test_type
>, test_type::first_type
>::value
,
31 "first type is int" );
33 static_assert( is_same
<Tuple_elt
<1, test_type
>, test_type::second_type
>::value
,
34 "second type is long" );
36 static_assert( is_same
<Tuple_elt
<0, const test_type
>,
37 const test_type::first_type
>::value
,
38 "first type is const int" );
40 static_assert( is_same
<Tuple_elt
<1, const test_type
>,
41 const test_type::second_type
>::value
,
42 "second type is const long" );
44 static_assert( is_same
<Tuple_elt
<0, volatile test_type
>,
45 volatile test_type::first_type
>::value
,
46 "first type is volatile int" );
48 static_assert( is_same
<Tuple_elt
<1, volatile test_type
>,
49 volatile test_type::second_type
>::value
,
50 "second type is volatile long" );
52 static_assert( is_same
<Tuple_elt
<0, const volatile test_type
>,
53 const volatile test_type::first_type
>::value
,
54 "first type is const volatile int" );
56 static_assert( is_same
<Tuple_elt
<1, const volatile test_type
>,
57 const volatile test_type::second_type
>::value
,
58 "second type is const volatile long" );