void_t.pass.cpp revision 06086258d3d8c48a916ec51c33e1ad8f46821b81
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#include <type_traits> 15 16#if _LIBCPP_STD_VER <= 14 17int main () {} 18#else 19 20template <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 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#endif 70