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 // type_traits
10
11 // void_t
12
13 // UNSUPPORTED: c++03, c++11, c++14
14
15 // XFAIL: gcc-5.1, gcc-5.2
16
17 #include <type_traits>
18
19 #include "test_macros.h"
20
21 template <class T>
test1()22 void test1()
23 {
24 ASSERT_SAME_TYPE(void, std::void_t<T>);
25 ASSERT_SAME_TYPE(void, std::void_t<const T>);
26 ASSERT_SAME_TYPE(void, std::void_t<volatile T>);
27 ASSERT_SAME_TYPE(void, std::void_t<const volatile T>);
28 }
29
30 template <class T, class U>
test2()31 void test2()
32 {
33 ASSERT_SAME_TYPE(void, std::void_t<T, U>);
34 ASSERT_SAME_TYPE(void, std::void_t<const T, U>);
35 ASSERT_SAME_TYPE(void, std::void_t<volatile T, U>);
36 ASSERT_SAME_TYPE(void, std::void_t<const volatile T, U>);
37
38 ASSERT_SAME_TYPE(void, std::void_t<U, T>);
39 ASSERT_SAME_TYPE(void, std::void_t<U, const T>);
40 ASSERT_SAME_TYPE(void, std::void_t<U, volatile T>);
41 ASSERT_SAME_TYPE(void, std::void_t<U, const volatile T>);
42
43 ASSERT_SAME_TYPE(void, std::void_t<T, const U>);
44 ASSERT_SAME_TYPE(void, std::void_t<const T, const U>);
45 ASSERT_SAME_TYPE(void, std::void_t<volatile T, const U>);
46 ASSERT_SAME_TYPE(void, std::void_t<const volatile T, const U>);
47 }
48
49 class Class
50 {
51 public:
52 ~Class();
53 };
54
main(int,char **)55 int main(int, char**)
56 {
57 ASSERT_SAME_TYPE(void, std::void_t<>);
58
59 test1<void>();
60 test1<int>();
61 test1<double>();
62 test1<int&>();
63 test1<Class>();
64 test1<Class[]>();
65 test1<Class[5]>();
66
67 test2<void, int>();
68 test2<double, int>();
69 test2<int&, int>();
70 test2<Class&, bool>();
71 test2<void *, int&>();
72
73 ASSERT_SAME_TYPE(void, std::void_t<int, double const &, Class, volatile int[], void>);
74
75 return 0;
76 }
77