| 1 |
// { dg-do compile { target c++14 } } |
| 2 |
|
| 3 |
// Copyright (C) 2015-2025 Free Software Foundation, Inc. |
| 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 <utility> |
| 21 |
#include <type_traits> |
| 22 |
|
| 23 |
typedef std::pair<int, long> test_type; |
| 24 |
|
| 25 |
template<std::size_t N, typename T> |
| 26 |
using Tuple_elt = std::tuple_element_t<N, T>; |
| 27 |
|
| 28 |
using std::is_same; |
| 29 |
|
| 30 |
static_assert( is_same<Tuple_elt<0, test_type>, test_type::first_type>::value, |
| 31 |
"first type is int" ); |
| 32 |
|
| 33 |
static_assert( is_same<Tuple_elt<1, test_type>, test_type::second_type>::value, |
| 34 |
"second type is long" ); |
| 35 |
|
| 36 |
static_assert( is_same<Tuple_elt<0, const test_type>, |
| 37 |
const test_type::first_type>::value, |
| 38 |
"first type is const int" ); |
| 39 |
|
| 40 |
static_assert( is_same<Tuple_elt<1, const test_type>, |
| 41 |
const test_type::second_type>::value, |
| 42 |
"second type is const long" ); |
| 43 |
|
| 44 |
static_assert( is_same<Tuple_elt<0, volatile test_type>, |
| 45 |
volatile test_type::first_type>::value, |
| 46 |
"first type is volatile int" ); |
| 47 |
|
| 48 |
static_assert( is_same<Tuple_elt<1, volatile test_type>, |
| 49 |
volatile test_type::second_type>::value, |
| 50 |
"second type is volatile long" ); |
| 51 |
|
| 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" ); |
| 55 |
|
| 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" ); |