| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// <array> |
| 10 |
|
| 11 |
// tuple_element<I, array<T, N> >::type |
| 12 |
|
| 13 |
#include <array> |
| 14 |
#include <type_traits> |
| 15 |
|
| 16 |
#include "test_macros.h" |
| 17 |
|
| 18 |
template <class T> |
| 19 |
void test() |
| 20 |
{ |
| 21 |
{ |
| 22 |
typedef T Exp; |
| 23 |
typedef std::array<T, 3> C; |
| 24 |
static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), ""); |
| 25 |
static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), ""); |
| 26 |
static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), ""); |
| 27 |
} |
| 28 |
{ |
| 29 |
typedef T const Exp; |
| 30 |
typedef std::array<T, 3> const C; |
| 31 |
static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), ""); |
| 32 |
static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), ""); |
| 33 |
static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), ""); |
| 34 |
} |
| 35 |
{ |
| 36 |
typedef T volatile Exp; |
| 37 |
typedef std::array<T, 3> volatile C; |
| 38 |
static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), ""); |
| 39 |
static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), ""); |
| 40 |
static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), ""); |
| 41 |
} |
| 42 |
{ |
| 43 |
typedef T const volatile Exp; |
| 44 |
typedef std::array<T, 3> const volatile C; |
| 45 |
static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), ""); |
| 46 |
static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), ""); |
| 47 |
static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), ""); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
int main(int, char**) |
| 52 |
{ |
| 53 |
test<double>(); |
| 54 |
test<int>(); |
| 55 |
|
| 56 |
return 0; |
| 57 |
} |