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

source code of libcxx/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp