| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++03 |
| 10 | |
| 11 | // Check that type traits derive from integral_constant |
| 12 | |
| 13 | // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS |
| 14 | |
| 15 | #include <cstddef> |
| 16 | #include <type_traits> |
| 17 | |
| 18 | #include "test_macros.h" |
| 19 | |
| 20 | static_assert(std::is_base_of<std::false_type, std::is_void<int>>::value, "" ); |
| 21 | static_assert(std::is_base_of<std::true_type, std::is_integral<int>>::value, "" ); |
| 22 | static_assert(std::is_base_of<std::false_type, std::is_floating_point<int>>::value, "" ); |
| 23 | static_assert(std::is_base_of<std::false_type, std::is_array<int>>::value, "" ); |
| 24 | static_assert(std::is_base_of<std::false_type, std::is_enum<int>>::value, "" ); |
| 25 | static_assert(std::is_base_of<std::false_type, std::is_union<int>>::value, "" ); |
| 26 | static_assert(std::is_base_of<std::false_type, std::is_class<int>>::value, "" ); |
| 27 | static_assert(std::is_base_of<std::false_type, std::is_function<int>>::value, "" ); |
| 28 | static_assert(std::is_base_of<std::false_type, std::is_pointer<int>>::value, "" ); |
| 29 | static_assert(std::is_base_of<std::false_type, std::is_lvalue_reference<int>>::value, "" ); |
| 30 | static_assert(std::is_base_of<std::false_type, std::is_rvalue_reference<int>>::value, "" ); |
| 31 | static_assert(std::is_base_of<std::false_type, std::is_member_object_pointer<int>>::value, "" ); |
| 32 | static_assert(std::is_base_of<std::false_type, std::is_member_function_pointer<int>>::value, "" ); |
| 33 | static_assert(std::is_base_of<std::true_type, std::is_fundamental<int>>::value, "" ); |
| 34 | static_assert(std::is_base_of<std::true_type, std::is_arithmetic<int>>::value, "" ); |
| 35 | static_assert(std::is_base_of<std::true_type, std::is_scalar<int>>::value, "" ); |
| 36 | static_assert(std::is_base_of<std::false_type, std::is_object<int&>>::value, "" ); |
| 37 | static_assert(std::is_base_of<std::false_type, std::is_compound<int>>::value, "" ); |
| 38 | static_assert(std::is_base_of<std::false_type, std::is_reference<int>>::value, "" ); |
| 39 | static_assert(std::is_base_of<std::false_type, std::is_member_pointer<int>>::value, "" ); |
| 40 | static_assert(std::is_base_of<std::false_type, std::is_const<int>>::value, "" ); |
| 41 | static_assert(std::is_base_of<std::false_type, std::is_volatile<int>>::value, "" ); |
| 42 | static_assert(std::is_base_of<std::true_type, std::is_trivial<int>>::value, "" ); |
| 43 | static_assert(std::is_base_of<std::true_type, std::is_trivially_copyable<int>>::value, "" ); |
| 44 | static_assert(std::is_base_of<std::true_type, std::is_standard_layout<int>>::value, "" ); |
| 45 | static_assert(std::is_base_of<std::true_type, std::is_pod<int>>::value, "" ); |
| 46 | static_assert(std::is_base_of<std::false_type, std::is_empty<int>>::value, "" ); |
| 47 | static_assert(std::is_base_of<std::false_type, std::is_polymorphic<int>>::value, "" ); |
| 48 | static_assert(std::is_base_of<std::false_type, std::is_abstract<int>>::value, "" ); |
| 49 | static_assert(std::is_base_of<std::true_type, std::is_signed<int>>::value, "" ); |
| 50 | static_assert(std::is_base_of<std::false_type, std::is_unsigned<int>>::value, "" ); |
| 51 | static_assert(std::is_base_of<std::true_type, std::is_constructible<int>>::value, "" ); |
| 52 | static_assert(std::is_base_of<std::true_type, std::is_trivially_constructible<int>>::value, "" ); |
| 53 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_constructible<int>>::value, "" ); |
| 54 | static_assert(std::is_base_of<std::true_type, std::is_default_constructible<int>>::value, "" ); |
| 55 | static_assert(std::is_base_of<std::true_type, std::is_trivially_default_constructible<int>>::value, "" ); |
| 56 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_default_constructible<int>>::value, "" ); |
| 57 | static_assert(std::is_base_of<std::true_type, std::is_copy_constructible<int>>::value, "" ); |
| 58 | static_assert(std::is_base_of<std::true_type, std::is_trivially_copy_constructible<int>>::value, "" ); |
| 59 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_copy_constructible<int>>::value, "" ); |
| 60 | static_assert(std::is_base_of<std::true_type, std::is_move_constructible<int>>::value, "" ); |
| 61 | static_assert(std::is_base_of<std::true_type, std::is_trivially_move_constructible<int>>::value, "" ); |
| 62 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_move_constructible<int>>::value, "" ); |
| 63 | static_assert(std::is_base_of<std::false_type, std::is_assignable<int, int>>::value, "" ); |
| 64 | static_assert(std::is_base_of<std::false_type, std::is_trivially_assignable<int, int>>::value, "" ); |
| 65 | static_assert(std::is_base_of<std::false_type, std::is_nothrow_assignable<int, int>>::value, "" ); |
| 66 | static_assert(std::is_base_of<std::true_type, std::is_copy_assignable<int>>::value, "" ); |
| 67 | static_assert(std::is_base_of<std::true_type, std::is_trivially_copy_assignable<int>>::value, "" ); |
| 68 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_copy_assignable<int>>::value, "" ); |
| 69 | static_assert(std::is_base_of<std::true_type, std::is_move_assignable<int>>::value, "" ); |
| 70 | static_assert(std::is_base_of<std::true_type, std::is_trivially_move_assignable<int>>::value, "" ); |
| 71 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_move_assignable<int>>::value, "" ); |
| 72 | static_assert(std::is_base_of<std::true_type, std::is_destructible<int>>::value, "" ); |
| 73 | static_assert(std::is_base_of<std::true_type, std::is_trivially_destructible<int>>::value, "" ); |
| 74 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_destructible<int>>::value, "" ); |
| 75 | static_assert(std::is_base_of<std::false_type, std::has_virtual_destructor<int>>::value, "" ); |
| 76 | static_assert(std::is_base_of<std::integral_constant<std::size_t, 1>, std::alignment_of<char>>::value, "" ); |
| 77 | static_assert(std::is_base_of<std::integral_constant<std::size_t, 0>, std::rank<char>>::value, "" ); |
| 78 | static_assert(std::is_base_of<std::integral_constant<std::size_t, 0>, std::extent<char>>::value, "" ); |
| 79 | static_assert(std::is_base_of<std::true_type, std::is_same<int, int>>::value, "" ); |
| 80 | static_assert(std::is_base_of<std::false_type, std::is_base_of<int, int>>::value, "" ); |
| 81 | static_assert(std::is_base_of<std::true_type, std::is_convertible<int, int>>::value, "" ); |
| 82 | #if TEST_STD_VER <= 17 |
| 83 | static_assert(std::is_base_of<std::true_type, std::is_literal_type<int>>::value, "" ); |
| 84 | #endif |
| 85 | #if TEST_STD_VER >= 14 |
| 86 | static_assert(std::is_base_of<std::false_type, std::is_null_pointer<int>>::value, "" ); |
| 87 | static_assert(std::is_base_of<std::false_type, std::is_final<int>>::value, "" ); |
| 88 | #endif |
| 89 | #if TEST_STD_VER >= 17 |
| 90 | static_assert(std::is_base_of<std::true_type, std::has_unique_object_representations<int>>::value, "" ); |
| 91 | static_assert(std::is_base_of<std::false_type, std::is_aggregate<int>>::value, "" ); |
| 92 | static_assert(std::is_base_of<std::false_type, std::is_swappable_with<int, int>>::value, "" ); |
| 93 | static_assert(std::is_base_of<std::true_type, std::is_swappable<int>>::value, "" ); |
| 94 | static_assert(std::is_base_of<std::false_type, std::is_nothrow_swappable_with<int, int>>::value, "" ); |
| 95 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_swappable<int>>::value, "" ); |
| 96 | static_assert(std::is_base_of<std::false_type, std::is_invocable<int>>::value, "" ); |
| 97 | static_assert(std::is_base_of<std::false_type, std::is_invocable_r<int, int>>::value, "" ); |
| 98 | static_assert(std::is_base_of<std::false_type, std::is_nothrow_invocable<int, int>>::value, "" ); |
| 99 | static_assert(std::is_base_of<std::false_type, std::is_nothrow_invocable_r<int, int>>::value, "" ); |
| 100 | #endif |
| 101 | #if TEST_STD_VER >= 20 |
| 102 | static_assert(std::is_base_of<std::false_type, std::is_bounded_array<int>>::value, "" ); |
| 103 | static_assert(std::is_base_of<std::false_type, std::is_unbounded_array<int>>::value, "" ); |
| 104 | static_assert(std::is_base_of<std::true_type, std::is_nothrow_convertible<int, int>>::value, "" ); |
| 105 | #endif |
| 106 | #if TEST_STD_VER >= 23 |
| 107 | # if defined(__cpp_lib_is_implicit_lifetime) && __cpp_lib_is_implicit_lifetime >= 202302L |
| 108 | static_assert(std::is_base_of<std::true_type, std::is_implicit_lifetime<int>>::value, "" ); |
| 109 | # endif |
| 110 | static_assert(std::is_base_of<std::false_type, std::is_scoped_enum<int>>::value, "" ); |
| 111 | #endif |
| 112 | #if TEST_STD_VER >= 26 |
| 113 | # if defined(__cpp_lib_is_virtual_base_of) && __cpp_lib_is_virtual_base_of >= 202406L |
| 114 | static_assert(std::is_base_of<std::false_type, std::is_virtual_base_of<int, int>>::value, "" ); |
| 115 | # endif |
| 116 | #endif |
| 117 | |