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