1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Chapter 1. The Type Traits Introspection Library</title> 5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="index.html" title="Chapter 1. The Type Traits Introspection Library"> 8<link rel="next" href="the_type_traits_introspection_library/tti_reason.html" title="Why the TTI Library ?"> 9</head> 10<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 11<table cellpadding="2" width="100%"><tr> 12<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 13<td align="center"><a href="../../../../index.html">Home</a></td> 14<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 15<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 16<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 17<td align="center"><a href="../../../../more/index.htm">More</a></td> 18</tr></table> 19<hr> 20<div class="spirit-nav"><a accesskey="n" href="the_type_traits_introspection_library/tti_reason.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div> 21<div class="chapter"> 22<div class="titlepage"><div> 23<div><h2 class="title"> 24<a name="tti"></a>Chapter 1. The Type Traits Introspection Library</h2></div> 25<div><div class="author"><h3 class="author"> 26<span class="firstname">Edward</span> <span class="surname">Diener</span> 27</h3></div></div> 28<div><p class="copyright">Copyright © 2011-2013 Tropic Software 29 East Inc</p></div> 30<div><div class="legalnotice"> 31<a name="tti.legal"></a><p> 32 Distributed under the Boost Software License, Version 1.0. (See accompanying 33 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 34 </p> 35</div></div> 36</div></div> 37<div class="toc"> 38<p><b>Table of Contents</b></p> 39<dl class="toc"> 40<dt><span class="section"><a href="index.html#the_type_traits_introspection_library.tti_intro">Introduction</a></span></dt> 41<dd><dl><dt><span class="section"><a href="index.html#the_type_traits_introspection_library.tti_intro.tti_headers">Header 42 Files</a></span></dt></dl></dd> 43<dt><span class="section"><a href="the_type_traits_introspection_library/tti_reason.html">Why the 44 TTI Library ?</a></span></dt> 45<dt><span class="section"><a href="the_type_traits_introspection_library/tti_terminology.html">Terminology</a></span></dt> 46<dt><span class="section"><a href="the_type_traits_introspection_library/tti_functionality.html">General 47 Functionality</a></span></dt> 48<dd><dl><dt><span class="section"><a href="the_type_traits_introspection_library/tti_functionality.html#the_type_traits_introspection_library.tti_functionality.tti_functionality_nm_gen">Macro 49 metafunction name generation considerations</a></span></dt></dl></dd> 50<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail.html">Macro 51 Metafunctions</a></span></dt> 52<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_type.html">Introspecting 53 an inner type</a></span></dt> 54<dd><dl><dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_type.html#the_type_traits_introspection_library.tti_detail_has_type.tti_detail_has_specific_type">Introspecting 55 a specific user-defined type</a></span></dt></dl></dd> 56<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_template.html">Introspecting 57 an inner class template</a></span></dt> 58<dd><dl> 59<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_template.html#the_type_traits_introspection_library.tti_detail_has_template.tti_detail_has_template_macro">Using 60 the BOOST_TTI_HAS_TEMPLATE macro</a></span></dt> 61<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_template/tti_detail_has_template_metafunction.html">Using 62 the has_template_(xxx) metafunction</a></span></dt> 63</dl></dd> 64<dt><span class="section"><a href="the_type_traits_introspection_library/tti_function_templates.html">Introspecting 65 function templates technique</a></span></dt> 66<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_member_data.html">Introspecting 67 member data</a></span></dt> 68<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_member_function.html">Introspecting 69 member function</a></span></dt> 70<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_member_function_template.html">Introspecting 71 member function template</a></span></dt> 72<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_static_member_data.html">Introspecting 73 static member data</a></span></dt> 74<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_static_member_function.html">Introspecting 75 static member function</a></span></dt> 76<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_static_member_function_template.html">Introspecting 77 static member function template</a></span></dt> 78<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_data.html">Introspecting 79 data</a></span></dt> 80<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_function.html">Introspecting 81 function</a></span></dt> 82<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_function_template.html">Introspecting 83 function template</a></span></dt> 84<dt><span class="section"><a href="the_type_traits_introspection_library/tti_nested_type.html">Nested 85 Types</a></span></dt> 86<dt><span class="section"><a href="the_type_traits_introspection_library/tti_func_sig.html">Nested 87 Types and Function Signatures</a></span></dt> 88<dt><span class="section"><a href="the_type_traits_introspection_library/tti_enclosing_type.html">Enclosing 89 Type</a></span></dt> 90<dt><span class="section"><a href="the_type_traits_introspection_library/tti_usingMM.html">An example 91 using the macro metafunctions</a></span></dt> 92<dt><span class="section"><a href="reference.html">Reference</a></span></dt> 93<dd><dl> 94<dt><span class="section"><a href="reference.html#header.boost.tti.gen.has_class_gen_hpp">Header <boost/tti/gen/has_class_gen.hpp></a></span></dt> 95<dd><dl></dl></dd> 96<dt><span class="section"><a href="header/boost/tti/gen/has_data_gen_hpp.html">Header <boost/tti/gen/has_data_gen.hpp></a></span></dt> 97<dd><dl></dl></dd> 98<dt><span class="section"><a href="header/boost/tti/gen/has_enum_gen_hpp.html">Header <boost/tti/gen/has_enum_gen.hpp></a></span></dt> 99<dd><dl></dl></dd> 100<dt><span class="section"><a href="header/boost/tti/gen/has_function_gen_hpp.html">Header <boost/tti/gen/has_function_gen.hpp></a></span></dt> 101<dd><dl></dl></dd> 102<dt><span class="section"><a href="header/boost/tti/gen/has_function_template_gen_hpp.html">Header <boost/tti/gen/has_function_template_gen.hpp></a></span></dt> 103<dd><dl></dl></dd> 104<dt><span class="section"><a href="header/boost/tti/gen/has_member_data_gen_hpp.html">Header <boost/tti/gen/has_member_data_gen.hpp></a></span></dt> 105<dd><dl></dl></dd> 106<dt><span class="section"><a href="header/boost/tti/gen/has_member_function_gen_hpp.html">Header <boost/tti/gen/has_member_function_gen.hpp></a></span></dt> 107<dd><dl></dl></dd> 108<dt><span class="section"><a href="header/boost/tti/gen/has_member_function_template_gen_hpp.html">Header <boost/tti/gen/has_member_function_template_gen.hpp></a></span></dt> 109<dd><dl></dl></dd> 110<dt><span class="section"><a href="header/boost/tti/gen/has_static_member_data_gen_hpp.html">Header <boost/tti/gen/has_static_member_data_gen.hpp></a></span></dt> 111<dd><dl></dl></dd> 112<dt><span class="section"><a href="header/boost/tti/gen/has_static_member_function_gen_hpp.html">Header <boost/tti/gen/has_static_member_function_gen.hpp></a></span></dt> 113<dd><dl></dl></dd> 114<dt><span class="section"><a href="header/boost/tti/gen/has_static_member_function_template_gen_hpp.html">Header <boost/tti/gen/has_static_member_function_template_gen.hpp></a></span></dt> 115<dd><dl></dl></dd> 116<dt><span class="section"><a href="header/boost/tti/gen/has_template_gen_hpp.html">Header <boost/tti/gen/has_template_gen.hpp></a></span></dt> 117<dd><dl></dl></dd> 118<dt><span class="section"><a href="header/boost/tti/gen/has_type_gen_hpp.html">Header <boost/tti/gen/has_type_gen.hpp></a></span></dt> 119<dd><dl></dl></dd> 120<dt><span class="section"><a href="header/boost/tti/gen/has_union_gen_hpp.html">Header <boost/tti/gen/has_union_gen.hpp></a></span></dt> 121<dd><dl></dl></dd> 122<dt><span class="section"><a href="header/boost/tti/gen/member_type_gen_hpp.html">Header <boost/tti/gen/member_type_gen.hpp></a></span></dt> 123<dd><dl></dl></dd> 124<dt><span class="section"><a href="header/boost/tti/gen/namespace_gen_hpp.html">Header <boost/tti/gen/namespace_gen.hpp></a></span></dt> 125<dd><dl></dl></dd> 126<dt><span class="section"><a href="header/boost/tti/has_class_hpp.html">Header <boost/tti/has_class.hpp></a></span></dt> 127<dd><dl></dl></dd> 128<dt><span class="section"><a href="header/boost/tti/has_data_hpp.html">Header <boost/tti/has_data.hpp></a></span></dt> 129<dd><dl></dl></dd> 130<dt><span class="section"><a href="header/boost/tti/has_enum_hpp.html">Header <boost/tti/has_enum.hpp></a></span></dt> 131<dd><dl></dl></dd> 132<dt><span class="section"><a href="header/boost/tti/has_function_hpp.html">Header <boost/tti/has_function.hpp></a></span></dt> 133<dd><dl></dl></dd> 134<dt><span class="section"><a href="header/boost/tti/has_function_template_hpp.html">Header <boost/tti/has_function_template.hpp></a></span></dt> 135<dd><dl></dl></dd> 136<dt><span class="section"><a href="header/boost/tti/has_member_data_hpp.html">Header <boost/tti/has_member_data.hpp></a></span></dt> 137<dd><dl></dl></dd> 138<dt><span class="section"><a href="header/boost/tti/has_member_function_hpp.html">Header <boost/tti/has_member_function.hpp></a></span></dt> 139<dd><dl></dl></dd> 140<dt><span class="section"><a href="header/boost/tti/has_member_function_template_hpp.html">Header <boost/tti/has_member_function_template.hpp></a></span></dt> 141<dd><dl></dl></dd> 142<dt><span class="section"><a href="header/boost/tti/has_static_member_data_hpp.html">Header <boost/tti/has_static_member_data.hpp></a></span></dt> 143<dd><dl></dl></dd> 144<dt><span class="section"><a href="header/boost/tti/has_static_member_function_hpp.html">Header <boost/tti/has_static_member_function.hpp></a></span></dt> 145<dd><dl></dl></dd> 146<dt><span class="section"><a href="header/boost/tti/has_static_member_function_template_hpp.html">Header <boost/tti/has_static_member_function_template.hpp></a></span></dt> 147<dd><dl></dl></dd> 148<dt><span class="section"><a href="header/boost/tti/has_template_hpp.html">Header <boost/tti/has_template.hpp></a></span></dt> 149<dd><dl></dl></dd> 150<dt><span class="section"><a href="header/boost/tti/has_type_hpp.html">Header <boost/tti/has_type.hpp></a></span></dt> 151<dd><dl></dl></dd> 152<dt><span class="section"><a href="header/boost/tti/has_union_hpp.html">Header <boost/tti/has_union.hpp></a></span></dt> 153<dd><dl></dl></dd> 154<dt><span class="section"><a href="header/boost/tti/member_type_hpp.html">Header <boost/tti/member_type.hpp></a></span></dt> 155<dd><dl></dl></dd> 156</dl></dd> 157<dt><span class="section"><a href="the_type_traits_introspection_library/tti_tests.html">Testing 158 TTI</a></span></dt> 159<dt><span class="section"><a href="the_type_traits_introspection_library/tti_history.html">History</a></span></dt> 160<dt><span class="section"><a href="the_type_traits_introspection_library/tti_todo.html">ToDo</a></span></dt> 161<dt><span class="section"><a href="the_type_traits_introspection_library/tti_acknowledgments.html">Acknowledgments</a></span></dt> 162<dt><span class="section"><a href="index/s27.html">Index</a></span></dt> 163</dl> 164</div> 165<div class="section"> 166<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 167<a name="the_type_traits_introspection_library.tti_intro"></a><a class="link" href="index.html#the_type_traits_introspection_library.tti_intro" title="Introduction">Introduction</a> 168</h2></div></div></div> 169<div class="toc"><dl class="toc"><dt><span class="section"><a href="index.html#the_type_traits_introspection_library.tti_intro.tti_headers">Header 170 Files</a></span></dt></dl></div> 171<p> 172 Welcome to the Boost Type Traits Introspection library, abbreviated TTI. 173 </p> 174<p> 175 TTI is a library which provides the ability to introspect by name the elements 176 of a type at compile time. 177 </p> 178<p> 179 TTI works through macros generating metafunctions. Metafunctions are class 180 templates of a particular syntax, having a nested 'type' member. So wherever 181 in C++ class templates can occur, TTI macros can be used. The metafunctions 182 generated by TTI are no different from any other metafunction as defined by 183 the Boost MPL library. 184 </p> 185<p> 186 The metafunctions generated by TTI are used to introspect elements of a type 187 at compile time, always passing at minimum to each metafunction the enclosing 188 type being introspected. 189 </p> 190<p> 191 The name of the library has been chosen because the library offers compile 192 time functionality on a type, similar to the Boost Type Traits library, and 193 because the functionality the library offers is the ability to introspect a 194 type about the existence of a specific element within that type. 195 </p> 196<p> 197 I use the word "introspect" in a very broad sense here. Normally 198 computer language introspection means initially asking for information to be 199 returned by name, which can then further be used to introspect for more specific 200 information. In the TTI library one must always know and supply the name, and 201 use the functionality provided for the correct type of inner element to find 202 out if that particular named entity exists. 203 </p> 204<p> 205 You may prefer the term "query" instead of "introspection" 206 to denote what this library does, but I use terminology based on the word "introspect" 207 throughout this documentation. 208 </p> 209<p> 210 The functionality of the library may be summed up as: 211 </p> 212<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 213<li class="listitem"> 214 Provide the means to introspect a type at compile time using a set of macros. 215 Each macro takes the name of the type's element and generates a metafunction 216 which can be subsequently invoked to determine whether or not the element 217 exists within the type. These generated metafunctions will be called "macro 218 metafunctions" in the documentation. The type to be introspected can 219 be a class, struct, or union. 220 </li> 221<li class="listitem"> 222 Provide the means to create a typedef for a type which may not exist. If 223 the type does not exist an empty marker type is returned as the typedef 224 type. This typedef type can be used as a type in the metafunctions of the 225 library without producing compile-time errors. 226 </li> 227</ul></div> 228<p> 229 The library is dependent on Boost PP, Boost MPL, Boost Type Traits, and Boost 230 Function Types. 231 </p> 232<p> 233 The library is also dependent on the variadic macro support of the Boost PP 234 library if the variadic macros in the library are used. 235 </p> 236<p> 237 The library is a header only library. 238 </p> 239<p> 240 Since the dependencies of the library are all header only libraries, there 241 is no need to build a library in order to use the TTI library. 242 </p> 243<div class="section"> 244<div class="titlepage"><div><div><h3 class="title"> 245<a name="the_type_traits_introspection_library.tti_intro.tti_headers"></a><a class="link" href="index.html#the_type_traits_introspection_library.tti_intro.tti_headers" title="Header Files">Header 246 Files</a> 247</h3></div></div></div> 248<p> 249 There is a single header file, <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">tti</span><span class="special">/</span><span class="identifier">tti</span><span class="special">.</span><span class="identifier">hpp</span></code>, 250 which includes all the header files in the library. 251 </p> 252<p> 253 There are also separate specific header files for each of the elements to 254 be introspected by the library. This allows for finer-grained inclusion of 255 the nested elements to be introspected. These header files are: 256 </p> 257<div class="table"> 258<a name="the_type_traits_introspection_library.tti_intro.tti_headers.tbhfiles"></a><p class="title"><b>Table 1.1. TTI Header Files</b></p> 259<div class="table-contents"><table class="table" summary="TTI Header Files"> 260<colgroup> 261<col> 262<col> 263</colgroup> 264<thead><tr> 265<th> 266 <p> 267 Introspected Element 268 </p> 269 </th> 270<th> 271 <p> 272 Specific Header File 273 </p> 274 </th> 275</tr></thead> 276<tbody> 277<tr> 278<td> 279 <p> 280 Type 281 </p> 282 </td> 283<td> 284 <p> 285 <code class="computeroutput"><a class="link" href="header/boost/tti/has_type_hpp.html" title="Header <boost/tti/has_type.hpp>">has_type.hpp</a></code> 286 </p> 287 </td> 288</tr> 289<tr> 290<td> 291 <p> 292 Class/Struct 293 </p> 294 </td> 295<td> 296 <p> 297 <code class="computeroutput"><a class="link" href="header/boost/tti/has_class_hpp.html" title="Header <boost/tti/has_class.hpp>">has_class.hpp</a></code> 298 </p> 299 </td> 300</tr> 301<tr> 302<td> 303 <p> 304 Enumeration 305 </p> 306 </td> 307<td> 308 <p> 309 <code class="computeroutput"><a class="link" href="header/boost/tti/has_enum_hpp.html" title="Header <boost/tti/has_enum.hpp>">has_enum.hpp</a></code> 310 </p> 311 </td> 312</tr> 313<tr> 314<td> 315 <p> 316 Union 317 </p> 318 </td> 319<td> 320 <p> 321 <code class="computeroutput"><a class="link" href="header/boost/tti/has_union_hpp.html" title="Header <boost/tti/has_union.hpp>">has_union.hpp</a></code> 322 </p> 323 </td> 324</tr> 325<tr> 326<td> 327 <p> 328 Class Template 329 </p> 330 </td> 331<td> 332 <p> 333 <code class="computeroutput"><a class="link" href="header/boost/tti/has_template_hpp.html" title="Header <boost/tti/has_template.hpp>">has_template.hpp</a></code> 334 </p> 335 </td> 336</tr> 337<tr> 338<td> 339 <p> 340 Member data 341 </p> 342 </td> 343<td> 344 <p> 345 <code class="computeroutput"><a class="link" href="header/boost/tti/has_member_data_hpp.html" title="Header <boost/tti/has_member_data.hpp>">has_member_data.hpp</a></code> 346 </p> 347 </td> 348</tr> 349<tr> 350<td> 351 <p> 352 Member function 353 </p> 354 </td> 355<td> 356 <p> 357 <code class="computeroutput"><a class="link" href="header/boost/tti/has_member_function_hpp.html" title="Header <boost/tti/has_member_function.hpp>">has_member_function.hpp</a></code> 358 </p> 359 </td> 360</tr> 361<tr> 362<td> 363 <p> 364 Member function template 365 </p> 366 </td> 367<td> 368 <p> 369 <code class="computeroutput"><a class="link" href="header/boost/tti/has_member_function_template_hpp.html" title="Header <boost/tti/has_member_function_template.hpp>">has_member_function_template.hpp</a></code> 370 </p> 371 </td> 372</tr> 373<tr> 374<td> 375 <p> 376 Static member data 377 </p> 378 </td> 379<td> 380 <p> 381 <code class="computeroutput"><a class="link" href="header/boost/tti/has_static_member_data_hpp.html" title="Header <boost/tti/has_static_member_data.hpp>">has_static_member_data.hpp</a></code> 382 </p> 383 </td> 384</tr> 385<tr> 386<td> 387 <p> 388 Static member function 389 </p> 390 </td> 391<td> 392 <p> 393 <code class="computeroutput"><a class="link" href="header/boost/tti/has_static_member_function_hpp.html" title="Header <boost/tti/has_static_member_function.hpp>">has_static_member_function.hpp</a></code> 394 </p> 395 </td> 396</tr> 397<tr> 398<td> 399 <p> 400 Static member function template 401 </p> 402 </td> 403<td> 404 <p> 405 <code class="computeroutput"><a class="link" href="header/boost/tti/has_static_member_function_template_hpp.html" title="Header <boost/tti/has_static_member_function_template.hpp>">has_static_member_function_template.hpp</a></code> 406 </p> 407 </td> 408</tr> 409<tr> 410<td> 411 <p> 412 Data 413 </p> 414 </td> 415<td> 416 <p> 417 <code class="computeroutput"><a class="link" href="header/boost/tti/has_data_hpp.html" title="Header <boost/tti/has_data.hpp>">has_data.hpp</a></code> 418 </p> 419 </td> 420</tr> 421<tr> 422<td> 423 <p> 424 Function 425 </p> 426 </td> 427<td> 428 <p> 429 <code class="computeroutput"><a class="link" href="header/boost/tti/has_function_hpp.html" title="Header <boost/tti/has_function.hpp>">has_function.hpp</a></code> 430 </p> 431 </td> 432</tr> 433<tr> 434<td> 435 <p> 436 Function template 437 </p> 438 </td> 439<td> 440 <p> 441 <code class="computeroutput"><a class="link" href="header/boost/tti/has_function_template_hpp.html" title="Header <boost/tti/has_function_template.hpp>">has_function_template.hpp</a></code> 442 </p> 443 </td> 444</tr> 445<tr> 446<td> 447 <p> 448 Member Type Creation 449 </p> 450 </td> 451<td> 452 <p> 453 <code class="computeroutput"><a class="link" href="header/boost/tti/member_type_hpp.html" title="Header <boost/tti/member_type.hpp>">member_type.hpp</a></code> 454 </p> 455 </td> 456</tr> 457</tbody> 458</table></div> 459</div> 460<br class="table-break"> 461</div> 462</div> 463</div> 464<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 465<td align="left"><p><small>Last revised: August 11, 2020 at 14:59:08 GMT</small></p></td> 466<td align="right"><div class="copyright-footer"></div></td> 467</tr></table> 468<hr> 469<div class="spirit-nav"><a accesskey="n" href="the_type_traits_introspection_library/tti_reason.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div> 470</body> 471</html> 472