]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/pair/astuple/astuple.cc
1 // { dg-do compile { target c++11 } }
3 // Copyright (C) 2013-2018 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/>.
20 // NB: Don't include any other headers in this file.
21 // LWG 2212 requires <utility> to define tuple_size<cv T> and
22 // tuple_element<cv T> specializations.
25 typedef std::pair
<int, long> test_type
;
27 static_assert( std::tuple_size
<test_type
>::value
== 2, "size is 2" );
28 static_assert( std::tuple_size
<const test_type
>::value
== 2, "size is 2" );
29 static_assert( std::tuple_size
<volatile test_type
>::value
== 2, "size is 2" );
30 static_assert( std::tuple_size
<const volatile test_type
>::value
== 2,
33 template<std::size_t N
, typename T
>
34 using Tuple_elt
= typename
std::tuple_element
<N
, T
>::type
;
36 // This relies on the fact that <utility> includes <type_traits>:
39 static_assert( is_same
<Tuple_elt
<0, test_type
>, test_type::first_type
>::value
,
40 "first type is int" );
42 static_assert( is_same
<Tuple_elt
<1, test_type
>, test_type::second_type
>::value
,
43 "second type is long" );
45 static_assert( is_same
<Tuple_elt
<0, const test_type
>,
46 const test_type::first_type
>::value
,
47 "first type is const int" );
49 static_assert( is_same
<Tuple_elt
<1, const test_type
>,
50 const test_type::second_type
>::value
,
51 "second type is const long" );
53 static_assert( is_same
<Tuple_elt
<0, volatile test_type
>,
54 volatile test_type::first_type
>::value
,
55 "first type is volatile int" );
57 static_assert( is_same
<Tuple_elt
<1, volatile test_type
>,
58 volatile test_type::second_type
>::value
,
59 "second type is volatile long" );
61 static_assert( is_same
<Tuple_elt
<0, const volatile test_type
>,
62 const volatile test_type::first_type
>::value
,
63 "first type is const volatile int" );
65 static_assert( is_same
<Tuple_elt
<1, const volatile test_type
>,
66 const volatile test_type::second_type
>::value
,
67 "second type is const volatile long" );