Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ --> |
| 4 | <html> |
| 5 | <head> |
| 6 | <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| 7 | <title>type traits intrinsic design</title> |
| 8 | <link type="text/css" rel="stylesheet" href="menu.css"> |
| 9 | <link type="text/css" rel="stylesheet" href="content.css"> |
| 10 | </head> |
| 11 | |
| 12 | <body> |
| 13 | <div id="menu"> |
| 14 | <div> |
| 15 | <a href="http://llvm.org/">LLVM Home</a> |
| 16 | </div> |
| 17 | |
| 18 | <div class="submenu"> |
| 19 | <label>libc++ Info</label> |
| 20 | <a href="/index.html">About</a> |
| 21 | </div> |
| 22 | |
| 23 | <div class="submenu"> |
| 24 | <label>Quick Links</label> |
| 25 | <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a> |
| 26 | <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a> |
| 27 | <a href="http://llvm.org/bugs/">Bug Reports</a> |
| 28 | <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a> |
| 29 | <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a> |
| 30 | </div> |
| 31 | </div> |
| 32 | |
| 33 | <div id="content"> |
| 34 | <!--*********************************************************************--> |
| 35 | <h1>Type traits intrinsic design</h1> |
| 36 | <!--*********************************************************************--> |
| 37 | |
| 38 | <p> |
| 39 | This is a survey of the type traits intrinsics clang has, and those needed. |
| 40 | The names and definitions of several of the needed type traits has recently |
| 41 | changed. Please see: |
| 42 | <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3142.html">N3142</a>. |
| 43 | </p> |
| 44 | |
| 45 | <blockquote> |
| 46 | <table border="1"> |
| 47 | <caption>Legend</caption> |
| 48 | |
| 49 | <tr> |
| 50 | <td>clang supplies it and it is absolutely necessary</td> |
| 51 | <td bgcolor="#80FF80"><tt>some_trait(T)</tt></td> |
| 52 | </tr> |
| 53 | |
| 54 | <tr> |
| 55 | <td>clang supplies it and it is useful</td> |
| 56 | <td bgcolor="#96B9FF"><tt>some_trait(T)</tt></td> |
| 57 | </tr> |
| 58 | |
| 59 | <tr> |
| 60 | <td>clang supplies it and it is not needed</td> |
| 61 | <td><tt>some_trait(T)</tt></td> |
| 62 | </tr> |
| 63 | |
| 64 | <tr> |
| 65 | <td>clang does not supply it and it is not needed</td> |
| 66 | <td></td> |
| 67 | </tr> |
| 68 | |
| 69 | <tr> |
| 70 | <td>clang does not supply it and it is absolutely necessary</td> |
| 71 | <td bgcolor="#FF5965"><tt>some_trait(T)</tt></td> |
| 72 | </tr> |
| 73 | |
| 74 | </table> |
| 75 | |
| 76 | <p></p> |
| 77 | |
| 78 | <table border="1"> |
| 79 | <caption>Needed type traits vs clang type traits</caption> |
| 80 | |
| 81 | <tr> |
| 82 | <th>libc++ Needs</th> |
| 83 | <th>clang Has</th> |
| 84 | </tr> |
| 85 | |
| 86 | <tr> |
| 87 | <td><tt>is_union<T></tt></td> |
| 88 | <td bgcolor="#80FF80"><tt>__is_union(T)</tt></td> |
| 89 | </tr> |
| 90 | |
| 91 | <tr> |
| 92 | <td><tt>is_class<T></tt></td> |
| 93 | <td bgcolor="#96B9FF"><tt>__is_class(T)</tt></td> |
| 94 | </tr> |
| 95 | |
| 96 | <tr> |
| 97 | <td><tt>is_enum<T></tt></td> |
| 98 | <td bgcolor="#96B9FF"><tt>__is_enum(T)</tt></td> |
| 99 | </tr> |
| 100 | |
| 101 | <tr> |
| 102 | <td><tt>is_pod<T></tt></td> |
| 103 | <td bgcolor="#80FF80"><tt>__is_pod(T)</tt></td> |
| 104 | </tr> |
| 105 | |
| 106 | <tr> |
| 107 | <td><tt>has_virtual_destructor<T></tt></td> |
| 108 | <td bgcolor="#80FF80"><tt>__has_virtual_destructor(T)</tt></td> |
| 109 | </tr> |
| 110 | |
| 111 | <tr> |
| 112 | <td><tt>is_constructible<T, Args...></tt></td> |
Howard Hinnant | 7bbce3c | 2011-05-13 00:01:01 +0000 | [diff] [blame] | 113 | <td></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 114 | </tr> |
| 115 | |
| 116 | <tr> |
| 117 | <td><tt>is_default_constructible<T></tt></td> |
| 118 | <td></td> |
| 119 | </tr> |
| 120 | |
| 121 | <tr> |
| 122 | <td><tt>is_copy_constructible<T></tt></td> |
| 123 | <td></td> |
| 124 | </tr> |
| 125 | |
| 126 | <tr> |
| 127 | <td><tt>is_move_constructible<T></tt></td> |
| 128 | <td></td> |
| 129 | </tr> |
| 130 | |
| 131 | <tr> |
| 132 | <td><tt>is_assignable<T, U></tt></td> |
Howard Hinnant | 7bbce3c | 2011-05-13 00:01:01 +0000 | [diff] [blame] | 133 | <td></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 134 | </tr> |
| 135 | |
| 136 | <tr> |
| 137 | <td><tt>is_copy_assignable<T></tt></td> |
| 138 | <td></td> |
| 139 | </tr> |
| 140 | |
| 141 | <tr> |
| 142 | <td><tt>is_move_assignable<T></tt></td> |
| 143 | <td></td> |
| 144 | </tr> |
| 145 | |
| 146 | <tr> |
| 147 | <td><tt>is_destructible<T></tt></td> |
Howard Hinnant | 0cfa1f7 | 2011-05-13 13:39:08 +0000 | [diff] [blame] | 148 | <td></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 149 | </tr> |
| 150 | |
| 151 | <tr> |
| 152 | <td><tt>is_trivially_constructible<T, Args...></tt></td> |
Howard Hinnant | 7d87f6b | 2012-07-19 15:59:52 +0000 | [diff] [blame] | 153 | <td bgcolor="#80FF80"><tt>__is_trivially_constructible(T, U)</tt></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 154 | </tr> |
| 155 | |
| 156 | <tr> |
| 157 | <td><tt>is_trivially_default_constructible<T></tt></td> |
Howard Hinnant | 7bbce3c | 2011-05-13 00:01:01 +0000 | [diff] [blame] | 158 | <td bgcolor="#80FF80"><tt>__has_trivial_constructor(T)</tt></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 159 | </tr> |
| 160 | |
| 161 | <tr> |
| 162 | <td><tt>is_trivially_copy_constructible<T></tt></td> |
| 163 | <td><tt>__has_trivial_copy(T)</tt></td> |
| 164 | </tr> |
| 165 | |
| 166 | <tr> |
| 167 | <td><tt>is_trivially_move_constructible<T></tt></td> |
| 168 | <td></td> |
| 169 | </tr> |
| 170 | |
| 171 | <tr> |
| 172 | <td><tt>is_trivially_assignable<T, U></tt></td> |
Howard Hinnant | 7d87f6b | 2012-07-19 15:59:52 +0000 | [diff] [blame] | 173 | <td bgcolor="#80FF80"><tt>__is_trivially_assignable(T, U)</tt></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 174 | </tr> |
| 175 | |
| 176 | <tr> |
| 177 | <td><tt>is_trivially_copy_assignable<T></tt></td> |
| 178 | <td><tt>__has_trivial_assign(T)</tt></td> |
| 179 | </tr> |
| 180 | |
| 181 | <tr> |
| 182 | <td><tt>is_trivially_move_assignable<T></tt></td> |
| 183 | <td></td> |
| 184 | </tr> |
| 185 | |
| 186 | <tr> |
| 187 | <td><tt>is_trivially_destructible<T></tt></td> |
| 188 | <td bgcolor="#80FF80"><tt>__has_trivial_destructor(T)</tt></td> |
| 189 | </tr> |
| 190 | |
| 191 | <tr> |
| 192 | <td><tt>is_nothrow_constructible<T, Args...></tt></td> |
Howard Hinnant | 7bbce3c | 2011-05-13 00:01:01 +0000 | [diff] [blame] | 193 | <td></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 194 | </tr> |
| 195 | |
| 196 | <tr> |
| 197 | <td><tt>is_nothrow_default_constructible<T></tt></td> |
| 198 | <td><tt>__has_nothrow_constructor(T)</tt></td> |
| 199 | </tr> |
| 200 | |
| 201 | <tr> |
| 202 | <td><tt>is_nothrow_copy_constructible<T></tt></td> |
| 203 | <td><tt>__has_nothrow_copy(T)</tt></td> |
| 204 | </tr> |
| 205 | |
| 206 | <tr> |
| 207 | <td><tt>is_nothrow_move_constructible<T></tt></td> |
| 208 | <td></td> |
| 209 | </tr> |
| 210 | |
| 211 | <tr> |
| 212 | <td><tt>is_nothrow_assignable<T, U></tt></td> |
Howard Hinnant | 7bbce3c | 2011-05-13 00:01:01 +0000 | [diff] [blame] | 213 | <td></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 214 | </tr> |
| 215 | |
| 216 | <tr> |
| 217 | <td><tt>is_nothrow_copy_assignable<T></tt></td> |
| 218 | <td><tt>__has_nothrow_assign(T)</tt></td> |
| 219 | </tr> |
| 220 | |
| 221 | <tr> |
| 222 | <td><tt>is_nothrow_move_assignable<T></tt></td> |
| 223 | <td></td> |
| 224 | </tr> |
| 225 | |
| 226 | <tr> |
| 227 | <td><tt>is_nothrow_destructible<T></tt></td> |
Howard Hinnant | 0cfa1f7 | 2011-05-13 13:39:08 +0000 | [diff] [blame] | 228 | <td></td> |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 229 | </tr> |
| 230 | |
Howard Hinnant | 01feecb | 2010-11-19 01:48:13 +0000 | [diff] [blame] | 231 | <tr> |
| 232 | <td><tt>is_trivial<T></tt></td> |
Howard Hinnant | 7bbce3c | 2011-05-13 00:01:01 +0000 | [diff] [blame] | 233 | <td bgcolor="#80FF80"><tt>__is_trivial(T)</tt></td> |
Howard Hinnant | 01feecb | 2010-11-19 01:48:13 +0000 | [diff] [blame] | 234 | </tr> |
| 235 | |
| 236 | <tr> |
| 237 | <td><tt>is_trivially_copyable<T></tt></td> |
Sean Hunt | 9e604b4 | 2011-05-13 00:32:09 +0000 | [diff] [blame] | 238 | <td bgcolor="#80FF80"><tt>__is_trivially_copyable(T)</tt></td> |
Howard Hinnant | 01feecb | 2010-11-19 01:48:13 +0000 | [diff] [blame] | 239 | </tr> |
| 240 | |
| 241 | <tr> |
| 242 | <td><tt>is_standard_layout<T></tt></td> |
Howard Hinnant | 7bbce3c | 2011-05-13 00:01:01 +0000 | [diff] [blame] | 243 | <td bgcolor="#80FF80"><tt>__is_standard_layout(T)</tt></td> |
Howard Hinnant | 01feecb | 2010-11-19 01:48:13 +0000 | [diff] [blame] | 244 | </tr> |
| 245 | |
| 246 | <tr> |
| 247 | <td><tt>is_literal_type<T></tt></td> |
Howard Hinnant | 3666695 | 2011-05-09 19:21:17 +0000 | [diff] [blame] | 248 | <td bgcolor="#80FF80"><tt>__is_literal_type(T)</tt></td> |
Howard Hinnant | 01feecb | 2010-11-19 01:48:13 +0000 | [diff] [blame] | 249 | </tr> |
| 250 | |
| 251 | <tr> |
| 252 | <td><tt>is_convertible<T, U></tt></td> |
Howard Hinnant | 3666695 | 2011-05-09 19:21:17 +0000 | [diff] [blame] | 253 | <td bgcolor="#80FF80"><tt>__is_convertible_to(T, U)</tt></td> |
Howard Hinnant | 01feecb | 2010-11-19 01:48:13 +0000 | [diff] [blame] | 254 | </tr> |
| 255 | |
| 256 | <tr> |
| 257 | <td><tt>is_base_of<T, U></tt></td> |
Howard Hinnant | 86e78d6 | 2011-03-26 19:58:42 +0000 | [diff] [blame] | 258 | <td bgcolor="#80FF80"><tt>__is_base_of(T, U)</tt></td> |
Howard Hinnant | 01feecb | 2010-11-19 01:48:13 +0000 | [diff] [blame] | 259 | </tr> |
| 260 | |
| 261 | <tr> |
| 262 | <td><tt>underlying_type<T></tt></td> |
Sean Hunt | 737a351 | 2011-07-18 18:37:21 +0000 | [diff] [blame] | 263 | <td bgcolor="#80FF80"><tt>__underlying_type(T)</tt></td> |
Howard Hinnant | 01feecb | 2010-11-19 01:48:13 +0000 | [diff] [blame] | 264 | </tr> |
| 265 | |
Howard Hinnant | 3666695 | 2011-05-09 19:21:17 +0000 | [diff] [blame] | 266 | <tr> |
| 267 | <td><tt>is_polymorphic<T></tt></td> |
| 268 | <td><tt>__is_polymorphic(T)</tt></td> |
| 269 | </tr> |
| 270 | |
| 271 | <tr> |
| 272 | <td><tt>is_empty<T></tt></td> |
| 273 | <td><tt>__is_empty(T)</tt></td> |
| 274 | </tr> |
| 275 | |
| 276 | <tr> |
| 277 | <td><tt>is_abstract<T></tt></td> |
| 278 | <td><tt>__is_abstract(T)</tt></td> |
| 279 | </tr> |
| 280 | |
Howard Hinnant | 9835d76 | 2010-11-19 01:38:58 +0000 | [diff] [blame] | 281 | </table> |
| 282 | </blockquote> |
| 283 | |
| 284 | </div> |
| 285 | </body> |
| 286 | </html> |