Debian Codegraph @

libcxx/test/std/utilities/meta/meta.trans/objc_support.compile.pass.mm

raw
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 // REQUIRES: objective-c++
10
11 // Simple test to check that type traits support Objective-C types.
12
13 // XFAIL: FROZEN-CXX03-HEADERS-FIXME
14
15 #include <type_traits>
16 #include "test_macros.h"
17
18 @interface I;
19 @end
20
21 // add_pointer
22 static_assert(std::is_same<std::add_pointer<id>::type, id*>::value, "");
23 static_assert(std::is_same<std::add_pointer<I>::type, I*>::value, "");
24
25 // add_lvalue_reference
26 static_assert(std::is_same<std::add_lvalue_reference<id>::type, id&>::value, "");
27 static_assert(std::is_same<std::add_lvalue_reference<I>::type, I&>::value, "");
28
29 // add_rvalue_reference
30 static_assert(std::is_same<std::add_rvalue_reference<id>::type, id&&>::value, "");
31 static_assert(std::is_same<std::add_rvalue_reference<I>::type, I&&>::value, "");
32
33 // decay
34 static_assert(std::is_same<std::decay<id>::type, id>::value, "");
35 static_assert(std::is_same<std::decay<I>::type, I>::value, "");
36 static_assert(std::is_same<std::decay<id(&)[5]>::type, id*>::value, "");
37
38 // __is_referenceable_v
39 LIBCPP_STATIC_ASSERT(std::__is_referenceable_v<id>, "");
40 LIBCPP_STATIC_ASSERT(std::__is_referenceable_v<id*>, "");
41 LIBCPP_STATIC_ASSERT(std::__is_referenceable_v<id&>, "");
42 LIBCPP_STATIC_ASSERT(std::__is_referenceable_v<id&&>, "");
43 LIBCPP_STATIC_ASSERT(std::__is_referenceable_v<I>, "");
44 LIBCPP_STATIC_ASSERT(std::__is_referenceable_v<I*>, "");
45 LIBCPP_STATIC_ASSERT(std::__is_referenceable_v<I&>, "");
46 LIBCPP_STATIC_ASSERT(std::__is_referenceable_v<I&&>, "");
47
48 // remove_all_extents
49 static_assert(std::is_same<std::remove_all_extents<id>::type, id>::value, "");
50 static_assert(std::is_same<std::remove_all_extents<id[5]>::type, id>::value, "");
51 static_assert(std::is_same<std::remove_all_extents<id[5][10]>::type, id>::value, "");
52 static_assert(std::is_same<std::remove_all_extents<I>::type, I>::value, "");
53
54 // remove_const
55 static_assert(std::is_same<std::remove_const<id>::type, id>::value, "");
56 static_assert(std::is_same<std::remove_const<const id>::type, id>::value, "");
57 static_assert(std::is_same<std::remove_const<I>::type, I>::value, "");
58 static_assert(std::is_same<std::remove_const<const I>::type, I>::value, "");
59
60 // remove_cv
61 static_assert(std::is_same<std::remove_cv<id>::type, id>::value, "");
62 static_assert(std::is_same<std::remove_cv<const volatile id>::type, id>::value, "");
63 static_assert(std::is_same<std::remove_cv<I>::type, I>::value, "");
64 static_assert(std::is_same<std::remove_cv<const volatile I>::type, I>::value, "");
65
66 #if TEST_STD_VER >= 20
67 // remove_cvref
68 static_assert(std::is_same<std::remove_cvref<id>::type, id>::value, "");
69 static_assert(std::is_same<std::remove_cvref<const volatile id&>::type, id>::value, "");
70 static_assert(std::is_same<std::remove_cvref<const volatile id&&>::type, id>::value, "");
71 static_assert(std::is_same<std::remove_cvref<I>::type, I>::value, "");
72 static_assert(std::is_same<std::remove_cvref<const volatile I&>::type, I>::value, "");
73 static_assert(std::is_same<std::remove_cvref<const volatile I&&>::type, I>::value, "");
74 #endif
75
76 // remove_extent
77 static_assert(std::is_same<std::remove_all_extents<id>::type, id>::value, "");
78 static_assert(std::is_same<std::remove_all_extents<id[5]>::type, id>::value, "");
79 static_assert(std::is_same<std::remove_all_extents<I>::type, I>::value, "");
80
81 // remove_pointer
82 static_assert(!std::is_same<std::remove_pointer<id>::type, id>::value, "");
83 // The result of removing and re-adding pointer to `id` should be still `id`.
84 static_assert(std::is_same<std::remove_pointer<id>::type*, id>::value, "");
85 static_assert(std::is_same<std::add_pointer<std::remove_pointer<id>::type>::type, id>::value, "");
86 static_assert(std::is_same<std::remove_pointer<std::add_pointer<id>::type>::type, id>::value, "");
87
88 // remove_reference
89 static_assert(std::is_same<std::remove_reference<id>::type, id>::value, "");
90 static_assert(std::is_same<std::remove_reference<id&>::type, id>::value, "");
91 static_assert(std::is_same<std::remove_reference<const id&>::type, const id>::value, "");
92 static_assert(std::is_same<std::remove_reference<id&&>::type, id>::value, "");
93 static_assert(std::is_same<std::remove_reference<const id&&>::type, const id>::value, "");
94 static_assert(std::is_same<std::remove_reference<I>::type, I>::value, "");
95 static_assert(std::is_same<std::remove_reference<I&>::type, I>::value, "");
96 static_assert(std::is_same<std::remove_reference<const I&>::type, const I>::value, "");
97 static_assert(std::is_same<std::remove_reference<I&&>::type, I>::value, "");
98 static_assert(std::is_same<std::remove_reference<const I&&>::type, const I>::value, "");
99
100 // remove_volatile
101 static_assert(std::is_same<std::remove_volatile<id>::type, id>::value, "");
102 static_assert(std::is_same<std::remove_volatile<volatile id>::type, id>::value, "");
103 static_assert(std::is_same<std::remove_volatile<I>::type, I>::value, "");
104 static_assert(std::is_same<std::remove_volatile<volatile I>::type, I>::value, "");
105
106 int main(int, char**) {
107 return 0;
108 }