blob: 5deeeff110d404d37ec89c03b998effeca08db58 [file] [log] [blame]
Marshall Clow88aae922014-11-17 15:50:08 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// type_traits
11
12// void_t
13
Eric Fiseliere39f4b92015-12-15 00:32:21 +000014#include <type_traits>
Marshall Clow88aae922014-11-17 15:50:08 +000015
Dan Albert1d4a1ed2016-05-25 22:36:09 -070016#if _LIBCPP_STD_VER <= 14
17int main () {}
18#else
19
Marshall Clow88aae922014-11-17 15:50:08 +000020template <class T>
21void test1()
22{
23 static_assert( std::is_same<void, std::void_t<T>>::value, "");
24 static_assert( std::is_same<void, std::void_t<const T>>::value, "");
25 static_assert( std::is_same<void, std::void_t<volatile T>>::value, "");
26 static_assert( std::is_same<void, std::void_t<const volatile T>>::value, "");
27}
28
29template <class T, class U>
30void test2()
31{
32 static_assert( std::is_same<void, std::void_t<T, U>>::value, "");
33 static_assert( std::is_same<void, std::void_t<const T, U>>::value, "");
34 static_assert( std::is_same<void, std::void_t<volatile T, U>>::value, "");
35 static_assert( std::is_same<void, std::void_t<const volatile T, U>>::value, "");
36
37 static_assert( std::is_same<void, std::void_t<T, const U>>::value, "");
38 static_assert( std::is_same<void, std::void_t<const T, const U>>::value, "");
39 static_assert( std::is_same<void, std::void_t<volatile T, const U>>::value, "");
40 static_assert( std::is_same<void, std::void_t<const volatile T, const U>>::value, "");
41}
42
43class Class
44{
45public:
46 ~Class();
47};
48
49int main()
50{
51 static_assert( std::is_same<void, std::void_t<>>::value, "");
52
Marshall Cloweea9d202015-01-28 20:26:11 +000053 test1<void>();
54 test1<int>();
55 test1<double>();
56 test1<int&>();
57 test1<Class>();
58 test1<Class[]>();
59 test1<Class[5]>();
60
61 test2<void, int>();
62 test2<double, int>();
63 test2<int&, int>();
64 test2<Class&, bool>();
65 test2<void *, int&>();
Marshall Clow88aae922014-11-17 15:50:08 +000066
67 static_assert( std::is_same<void, std::void_t<int, double const &, Class, volatile int[], void>>::value, "");
68}
Dan Albert1d4a1ed2016-05-25 22:36:09 -070069#endif