xref: /llvm-project/libcxx/test/std/numerics/complex.number/complex.tuple/tuple_size.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<class T> struct tuple_size;
14 
15 #include <cassert>
16 #include <complex>
17 #include <concepts>
18 
19 template <typename C>
20 concept HasTupleSize = requires { std::tuple_size<C>{}; };
21 
22 struct SomeObject {};
23 
24 static_assert(!HasTupleSize<SomeObject>);
25 
26 template <typename T>
test()27 void test() {
28   using C = std::complex<T>;
29 
30   static_assert(HasTupleSize<C>);
31   static_assert(std::same_as<typename std::tuple_size<C>::value_type, size_t>);
32   static_assert(std::tuple_size<C>() == 2);
33 }
34 
test()35 void test() {
36   test<float>();
37   test<double>();
38   test<long double>();
39 }
40