Marshall Clow | 88aae92 | 2014-11-17 15:50:08 +0000 | [diff] [blame] | 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 | |
Eric Fiselier | e39f4b9 | 2015-12-15 00:32:21 +0000 | [diff] [blame] | 14 | #include <type_traits> |
Marshall Clow | 88aae92 | 2014-11-17 15:50:08 +0000 | [diff] [blame] | 15 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 16 | #if _LIBCPP_STD_VER <= 14 |
| 17 | int main () {} |
| 18 | #else |
| 19 | |
Marshall Clow | 88aae92 | 2014-11-17 15:50:08 +0000 | [diff] [blame] | 20 | template <class T> |
| 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> |
| 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 | |
| 49 | int main() |
| 50 | { |
| 51 | static_assert( std::is_same<void, std::void_t<>>::value, ""); |
| 52 | |
Marshall Clow | eea9d20 | 2015-01-28 20:26:11 +0000 | [diff] [blame] | 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&>(); |
Marshall Clow | 88aae92 | 2014-11-17 15:50:08 +0000 | [diff] [blame] | 66 | |
| 67 | static_assert( std::is_same<void, std::void_t<int, double const &, Class, volatile int[], void>>::value, ""); |
| 68 | } |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 69 | #endif |