xref: /llvm-project/libcxx/test/std/numerics/complex.number/complex.tuple/tuple_element.compile.pass.cpp (revision 2ea5d167ae43bed5a511d5d819ae7c52cc76ec5c)
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 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
10 
11 // <complex>
12 
13 //   template<size_t I, class T> struct tuple_element;
14 
15 #include <cassert>
16 #include <complex>
17 #include <concepts>
18 
19 template <size_t I, typename C>
20 concept HasTupleElement = requires { std::tuple_element<I, C>{}; };
21 
22 struct SomeObject {};
23 
24 static_assert(!HasTupleElement<0, SomeObject>);
25 static_assert(!HasTupleElement<1, SomeObject>);
26 static_assert(!HasTupleElement<3, SomeObject>);
27 
28 template <typename T>
test()29 void test() {
30   using C = std::complex<T>;
31 
32   static_assert(HasTupleElement<0, C>);
33   static_assert(HasTupleElement<1, C>);
34 
35   static_assert(std::same_as<typename std::tuple_element<0, C>::type, T>);
36   static_assert(std::same_as<typename std::tuple_element<1, C>::type, T>);
37 }
38 
test()39 void test() {
40   test<float>();
41   test<double>();
42   test<long double>();
43 }
44