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 // <tuple>
10
11 // template <class... Types> class tuple;
12
13 // template <class... Types>
14 // struct tuple_size<tuple<Types...>>
15 // : public integral_constant<size_t, sizeof...(Types)> { };
16
17 // UNSUPPORTED: c++03
18
19 #include <tuple>
20 #include <array>
21 #include <type_traits>
22
23 #include "test_macros.h"
24
25 template <class T, size_t Size = sizeof(std::tuple_size<T>)>
is_complete(int)26 constexpr bool is_complete(int) { static_assert(Size > 0, ""); return true; }
is_complete(long)27 template <class> constexpr bool is_complete(long) { return false; }
is_complete()28 template <class T> constexpr bool is_complete() { return is_complete<T>(0); }
29
30 struct Dummy1 {};
31 struct Dummy2 {};
32
33 namespace std {
34 template <> struct tuple_size<Dummy1> : public integral_constant<size_t, 0> {};
35 }
36
37 template <class T>
test_complete()38 void test_complete() {
39 static_assert(is_complete<T>(), "");
40 static_assert(is_complete<const T>(), "");
41 static_assert(is_complete<volatile T>(), "");
42 static_assert(is_complete<const volatile T>(), "");
43 }
44
45 template <class T>
test_incomplete()46 void test_incomplete() {
47 static_assert(!is_complete<T>(), "");
48 static_assert(!is_complete<const T>(), "");
49 static_assert(!is_complete<volatile T>(), "");
50 static_assert(!is_complete<const volatile T>(), "");
51 }
52
53
main(int,char **)54 int main(int, char**)
55 {
56 test_complete<std::tuple<> >();
57 test_complete<std::tuple<int&> >();
58 test_complete<std::tuple<int&&, int&, void*>>();
59 test_complete<std::pair<int, long> >();
60 test_complete<std::array<int, 5> >();
61 test_complete<Dummy1>();
62
63 test_incomplete<void>();
64 test_incomplete<int>();
65 test_incomplete<std::tuple<int>&>();
66 test_incomplete<Dummy2>();
67
68 return 0;
69 }
70