• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
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 
14 // UNSUPPORTED: c++98, c++03, c++11, c++14
15 
16 // XFAIL: gcc-5.1, gcc-5.2
17 
18 #include <type_traits>
19 
20 template <class T>
test1()21 void 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 
29 template <class T, class U>
test2()30 void 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 
43 class Class
44 {
45 public:
46     ~Class();
47 };
48 
main()49 int main()
50 {
51     static_assert( std::is_same<void, std::void_t<>>::value, "");
52 
53     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&>();
66 
67     static_assert( std::is_same<void, std::void_t<int, double const &, Class, volatile int[], void>>::value, "");
68 }
69