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 // <experimental/type_traits> 11 12 #include <experimental/type_traits> 13 14 #if _LIBCPP_STD_VER > 11 15 16 namespace ex = std::experimental; 17 18 struct base_type {}; 19 struct derived_type : base_type {}; 20 21 int main() 22 { 23 { 24 typedef int T; 25 typedef int U; 26 static_assert(ex::is_same_v<T, U>, ""); 27 static_assert(std::is_same<decltype(ex::is_same_v<T, U>), const bool>::value, ""); 28 static_assert(ex::is_same_v<T, U> == std::is_same<T, U>::value, ""); 29 } 30 { 31 typedef int T; 32 typedef long U; 33 static_assert(!ex::is_same_v<T, U>, ""); 34 static_assert(ex::is_same_v<T, U> == std::is_same<T, U>::value, ""); 35 } 36 { 37 typedef base_type T; 38 typedef derived_type U; 39 static_assert(ex::is_base_of_v<T, U>, ""); 40 static_assert(std::is_same<decltype(ex::is_base_of_v<T, U>), const bool>::value, ""); 41 static_assert(ex::is_base_of_v<T, U> == std::is_base_of<T, U>::value, ""); 42 } 43 { 44 typedef int T; 45 typedef int U; 46 static_assert(!ex::is_base_of_v<T, U>, ""); 47 static_assert(ex::is_base_of_v<T, U> == std::is_base_of<T, U>::value, ""); 48 } 49 { 50 typedef int T; 51 typedef long U; 52 static_assert(ex::is_convertible_v<T, U>, ""); 53 static_assert(std::is_same<decltype(ex::is_convertible_v<T, U>), const bool>::value, ""); 54 static_assert(ex::is_convertible_v<T, U> == std::is_convertible<T, U>::value, ""); 55 } 56 { 57 typedef void T; 58 typedef int U; 59 static_assert(!ex::is_convertible_v<T, U>, ""); 60 static_assert(ex::is_convertible_v<T, U> == std::is_convertible<T, U>::value, ""); 61 } 62 } 63 #else /* _LIBCPP_STD_VER <= 11 */ 64 int main() {} 65 #endif /* _LIBCPP_STD_VER > 11 */ 66