xref: /llvm-project/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp (revision 7fc6a55688c816f5fc1a5481ae7af25be7500356)
15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <array>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // tuple_element<I, array<T, N> >::type
125a83710eSEric Fiselier 
135a83710eSEric Fiselier #include <array>
145a83710eSEric Fiselier #include <type_traits>
155a83710eSEric Fiselier 
16*7fc6a556SMarshall Clow #include "test_macros.h"
17*7fc6a556SMarshall Clow 
1857f00f2fSEric Fiselier template <class T>
test()1957f00f2fSEric Fiselier void test()
2057f00f2fSEric Fiselier {
2157f00f2fSEric Fiselier     {
2257f00f2fSEric Fiselier     typedef T Exp;
2357f00f2fSEric Fiselier     typedef std::array<T, 3> C;
2457f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
2557f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
2657f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
2757f00f2fSEric Fiselier     }
2857f00f2fSEric Fiselier     {
2957f00f2fSEric Fiselier     typedef T const Exp;
3057f00f2fSEric Fiselier     typedef std::array<T, 3> const C;
3157f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
3257f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
3357f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
3457f00f2fSEric Fiselier     }
3557f00f2fSEric Fiselier     {
3657f00f2fSEric Fiselier     typedef T volatile Exp;
3757f00f2fSEric Fiselier     typedef std::array<T, 3> volatile C;
3857f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
3957f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
4057f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
4157f00f2fSEric Fiselier     }
4257f00f2fSEric Fiselier     {
4357f00f2fSEric Fiselier     typedef T const volatile Exp;
4457f00f2fSEric Fiselier     typedef std::array<T, 3> const volatile C;
4557f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
4657f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
4757f00f2fSEric Fiselier     static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
4857f00f2fSEric Fiselier     }
4957f00f2fSEric Fiselier }
5057f00f2fSEric Fiselier 
main(int,char **)512df59c50SJF Bastien int main(int, char**)
525a83710eSEric Fiselier {
5357f00f2fSEric Fiselier     test<double>();
5457f00f2fSEric Fiselier     test<int>();
552df59c50SJF Bastien 
562df59c50SJF Bastien   return 0;
575a83710eSEric Fiselier }
58