index.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Chapter&#160;1.&#160;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&#160;1.&#160;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&#160;1.&#160;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 &#169; 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. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_template.html">Introspecting
  55. an inner class template</a></span></dt>
  56. <dd><dl>
  57. <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
  58. the BOOST_TTI_HAS_TEMPLATE macro</a></span></dt>
  59. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_template/tti_detail_has_template_metafunction.html">Using
  60. the has_template_(xxx) metafunction</a></span></dt>
  61. </dl></dd>
  62. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_member_data.html">Introspecting
  63. member data</a></span></dt>
  64. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_member_function.html">Introspecting
  65. member function</a></span></dt>
  66. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_static_member_data.html">Introspecting
  67. static member data</a></span></dt>
  68. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_static_member_function.html">Introspecting
  69. static member function</a></span></dt>
  70. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_data.html">Introspecting
  71. inner data</a></span></dt>
  72. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_function.html">Introspecting
  73. an inner function</a></span></dt>
  74. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_nested_type.html">Nested
  75. Types</a></span></dt>
  76. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_func_sig.html">Nested
  77. Types and Function Signatures</a></span></dt>
  78. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_enclosing_type.html">Enclosing
  79. Type</a></span></dt>
  80. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_usingMM.html">An example
  81. using the Macro Metafunctions</a></span></dt>
  82. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_func_templates.html">Introspecting
  83. Function Templates</a></span></dt>
  84. <dt><span class="section"><a href="reference.html">Reference</a></span></dt>
  85. <dd><dl>
  86. <dt><span class="section"><a href="reference.html#header.boost.tti.gen.has_data_gen_hpp">Header &lt;boost/tti/gen/has_data_gen.hpp&gt;</a></span></dt>
  87. <dd><dl></dl></dd>
  88. <dt><span class="section"><a href="header/boost/tti/gen/has_function_gen_hpp.html">Header &lt;boost/tti/gen/has_function_gen.hpp&gt;</a></span></dt>
  89. <dd><dl></dl></dd>
  90. <dt><span class="section"><a href="header/boost/tti/gen/has_member_data_gen_hpp.html">Header &lt;boost/tti/gen/has_member_data_gen.hpp&gt;</a></span></dt>
  91. <dd><dl></dl></dd>
  92. <dt><span class="section"><a href="header/boost/tti/gen/has_member_function_gen_hpp.html">Header &lt;boost/tti/gen/has_member_function_gen.hpp&gt;</a></span></dt>
  93. <dd><dl></dl></dd>
  94. <dt><span class="section"><a href="header/boost/tti/gen/has_static_member_data_gen_hpp.html">Header &lt;boost/tti/gen/has_static_member_data_gen.hpp&gt;</a></span></dt>
  95. <dd><dl></dl></dd>
  96. <dt><span class="section"><a href="header/boost/tti/gen/has_static_member_function_gen_hpp.html">Header &lt;boost/tti/gen/has_static_member_function_gen.hpp&gt;</a></span></dt>
  97. <dd><dl></dl></dd>
  98. <dt><span class="section"><a href="header/boost/tti/gen/has_template_gen_hpp.html">Header &lt;boost/tti/gen/has_template_gen.hpp&gt;</a></span></dt>
  99. <dd><dl></dl></dd>
  100. <dt><span class="section"><a href="header/boost/tti/gen/has_type_gen_hpp.html">Header &lt;boost/tti/gen/has_type_gen.hpp&gt;</a></span></dt>
  101. <dd><dl></dl></dd>
  102. <dt><span class="section"><a href="header/boost/tti/gen/member_type_gen_hpp.html">Header &lt;boost/tti/gen/member_type_gen.hpp&gt;</a></span></dt>
  103. <dd><dl></dl></dd>
  104. <dt><span class="section"><a href="header/boost/tti/gen/namespace_gen_hpp.html">Header &lt;boost/tti/gen/namespace_gen.hpp&gt;</a></span></dt>
  105. <dd><dl></dl></dd>
  106. <dt><span class="section"><a href="header/boost/tti/has_data_hpp.html">Header &lt;boost/tti/has_data.hpp&gt;</a></span></dt>
  107. <dd><dl></dl></dd>
  108. <dt><span class="section"><a href="header/boost/tti/has_function_hpp.html">Header &lt;boost/tti/has_function.hpp&gt;</a></span></dt>
  109. <dd><dl></dl></dd>
  110. <dt><span class="section"><a href="header/boost/tti/has_member_data_hpp.html">Header &lt;boost/tti/has_member_data.hpp&gt;</a></span></dt>
  111. <dd><dl></dl></dd>
  112. <dt><span class="section"><a href="header/boost/tti/has_member_function_hpp.html">Header &lt;boost/tti/has_member_function.hpp&gt;</a></span></dt>
  113. <dd><dl></dl></dd>
  114. <dt><span class="section"><a href="header/boost/tti/has_static_member_data_hpp.html">Header &lt;boost/tti/has_static_member_data.hpp&gt;</a></span></dt>
  115. <dd><dl></dl></dd>
  116. <dt><span class="section"><a href="header/boost/tti/has_static_member_function_hpp.html">Header &lt;boost/tti/has_static_member_function.hpp&gt;</a></span></dt>
  117. <dd><dl></dl></dd>
  118. <dt><span class="section"><a href="header/boost/tti/has_template_hpp.html">Header &lt;boost/tti/has_template.hpp&gt;</a></span></dt>
  119. <dd><dl></dl></dd>
  120. <dt><span class="section"><a href="header/boost/tti/has_type_hpp.html">Header &lt;boost/tti/has_type.hpp&gt;</a></span></dt>
  121. <dd><dl></dl></dd>
  122. <dt><span class="section"><a href="header/boost/tti/member_type_hpp.html">Header &lt;boost/tti/member_type.hpp&gt;</a></span></dt>
  123. <dd><dl></dl></dd>
  124. </dl></dd>
  125. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_tests.html">Testing
  126. TTI</a></span></dt>
  127. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_history.html">History</a></span></dt>
  128. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_todo.html">ToDo</a></span></dt>
  129. <dt><span class="section"><a href="the_type_traits_introspection_library/tti_acknowledgments.html">Acknowledgments</a></span></dt>
  130. <dt><span class="section"><a href="index/s24.html">Index</a></span></dt>
  131. </dl>
  132. </div>
  133. <div class="section">
  134. <div class="titlepage"><div><div><h2 class="title" style="clear: both">
  135. <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>
  136. </h2></div></div></div>
  137. <div class="toc"><dl class="toc"><dt><span class="section"><a href="index.html#the_type_traits_introspection_library.tti_intro.tti_headers">Header
  138. Files</a></span></dt></dl></div>
  139. <p>
  140. Welcome to the Boost Type Traits Introspection library, abbreviated TTI.
  141. </p>
  142. <p>
  143. TTI is a library which provides the ability to introspect by name the elements
  144. of a type at compile time.
  145. </p>
  146. <p>
  147. TTI works through macros generating metafunctions. Metafunctions are class
  148. templates of a particular syntax, having a nested 'type' member. So wherever
  149. in C++ class templates can occur, TTI macros can be used. The metafunctions
  150. generated by TTI are no different from any other metafunction as defined by
  151. the Boost MPL library.
  152. </p>
  153. <p>
  154. The metafunctions generated by TTI are used to introspect elements of a type
  155. at compile time, always passing at minimum to each metafunction the enclosing
  156. type being introspected.
  157. </p>
  158. <p>
  159. The name of the library has been chosen because the library offers compile
  160. time functionality on a type, similar to the Boost Type Traits library, and
  161. because the functionality the library offers is the ability to introspect a
  162. type about the existence of a specific element within that type.
  163. </p>
  164. <p>
  165. I use the word "introspect" in a very broad sense here. Normally
  166. computer language introspection means initially asking for information to be
  167. returned by name, which can then further be used to introspect for more specific
  168. information. In the TTI library one must always know and supply the name, and
  169. use the functionality provided for the correct type of inner element to find
  170. out if that particular named entity exists.
  171. </p>
  172. <p>
  173. You may prefer the term "query" instead of "introspection"
  174. to denote what this library does, but I use terminology based on the word "introspect"
  175. throughout this documentation.
  176. </p>
  177. <p>
  178. The functionality of the library may be summed up as:
  179. </p>
  180. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
  181. <li class="listitem">
  182. Provide the means to introspect a type at compile time using a set of macros.
  183. Each macro takes the name of the type's element and generates a metafunction
  184. which can be subsequently invoked to determine whether or not the element
  185. exists within the type. These generated metafunctions will be called "macro
  186. metafunctions" in the documentation.
  187. </li>
  188. <li class="listitem">
  189. Provide the means to create a typedef for a type which may not exist. This
  190. typedef type can be used as a type in the metafunctions of the library
  191. without producing compile-time errors.
  192. </li>
  193. </ul></div>
  194. <p>
  195. The library is dependent on Boost PP, Boost MPL, Boost Type Traits, and Boost
  196. Function Types.
  197. </p>
  198. <p>
  199. The library is also dependent on the variadic macro support of the Boost PP
  200. library if the variadic macros in the library are used.
  201. </p>
  202. <p>
  203. The library is a header only library.
  204. </p>
  205. <p>
  206. Since the dependencies of the library are all header only libraries, there
  207. is no need to build a library in order to use the TTI library.
  208. </p>
  209. <div class="section">
  210. <div class="titlepage"><div><div><h3 class="title">
  211. <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
  212. Files</a>
  213. </h3></div></div></div>
  214. <p>
  215. There are 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>,
  216. which includes all the header files in the library.
  217. </p>
  218. <p>
  219. There are also separate specific header files for each of the elements to
  220. be introspected by the library. This allows for finer-grained inclusion of
  221. the nested elements to be introspected. These header files are:
  222. </p>
  223. <div class="table">
  224. <a name="the_type_traits_introspection_library.tti_intro.tti_headers.tbhfiles"></a><p class="title"><b>Table&#160;1.1.&#160;TTI Header Files</b></p>
  225. <div class="table-contents"><table class="table" summary="TTI Header Files">
  226. <colgroup>
  227. <col>
  228. <col>
  229. </colgroup>
  230. <thead><tr>
  231. <th>
  232. <p>
  233. Introspected Element
  234. </p>
  235. </th>
  236. <th>
  237. <p>
  238. Specific Header File
  239. </p>
  240. </th>
  241. </tr></thead>
  242. <tbody>
  243. <tr>
  244. <td>
  245. <p>
  246. Type
  247. </p>
  248. </td>
  249. <td>
  250. <p>
  251. <code class="computeroutput"><a class="link" href="header/boost/tti/has_type_hpp.html" title="Header &lt;boost/tti/has_type.hpp&gt;">has_type.hpp</a></code>
  252. </p>
  253. </td>
  254. </tr>
  255. <tr>
  256. <td>
  257. <p>
  258. Class Template
  259. </p>
  260. </td>
  261. <td>
  262. <p>
  263. <code class="computeroutput"><a class="link" href="header/boost/tti/has_template_hpp.html" title="Header &lt;boost/tti/has_template.hpp&gt;">has_template.hpp</a></code>
  264. </p>
  265. </td>
  266. </tr>
  267. <tr>
  268. <td>
  269. <p>
  270. Member data
  271. </p>
  272. </td>
  273. <td>
  274. <p>
  275. <code class="computeroutput"><a class="link" href="header/boost/tti/has_member_data_hpp.html" title="Header &lt;boost/tti/has_member_data.hpp&gt;">has_member_data.hpp</a></code>
  276. </p>
  277. </td>
  278. </tr>
  279. <tr>
  280. <td>
  281. <p>
  282. Member function
  283. </p>
  284. </td>
  285. <td>
  286. <p>
  287. <code class="computeroutput"><a class="link" href="header/boost/tti/has_member_function_hpp.html" title="Header &lt;boost/tti/has_member_function.hpp&gt;">has_member_function.hpp</a></code>
  288. </p>
  289. </td>
  290. </tr>
  291. <tr>
  292. <td>
  293. <p>
  294. Static member data
  295. </p>
  296. </td>
  297. <td>
  298. <p>
  299. <code class="computeroutput"><a class="link" href="header/boost/tti/has_static_member_data_hpp.html" title="Header &lt;boost/tti/has_static_member_data.hpp&gt;">has_static_member_data.hpp</a></code>
  300. </p>
  301. </td>
  302. </tr>
  303. <tr>
  304. <td>
  305. <p>
  306. Static member function
  307. </p>
  308. </td>
  309. <td>
  310. <p>
  311. <code class="computeroutput"><a class="link" href="header/boost/tti/has_static_member_function_hpp.html" title="Header &lt;boost/tti/has_static_member_function.hpp&gt;">has_static_member_function.hpp</a></code>
  312. </p>
  313. </td>
  314. </tr>
  315. <tr>
  316. <td>
  317. <p>
  318. Data
  319. </p>
  320. </td>
  321. <td>
  322. <p>
  323. <code class="computeroutput"><a class="link" href="header/boost/tti/has_data_hpp.html" title="Header &lt;boost/tti/has_data.hpp&gt;">has_data.hpp</a></code>
  324. </p>
  325. </td>
  326. </tr>
  327. <tr>
  328. <td>
  329. <p>
  330. Function
  331. </p>
  332. </td>
  333. <td>
  334. <p>
  335. <code class="computeroutput"><a class="link" href="header/boost/tti/has_function_hpp.html" title="Header &lt;boost/tti/has_function.hpp&gt;">has_function.hpp</a></code>
  336. </p>
  337. </td>
  338. </tr>
  339. <tr>
  340. <td>
  341. <p>
  342. Member Type Creation
  343. </p>
  344. </td>
  345. <td>
  346. <p>
  347. <code class="computeroutput"><a class="link" href="header/boost/tti/member_type_hpp.html" title="Header &lt;boost/tti/member_type.hpp&gt;">member_type.hpp</a></code>
  348. </p>
  349. </td>
  350. </tr>
  351. </tbody>
  352. </table></div>
  353. </div>
  354. <br class="table-break">
  355. </div>
  356. </div>
  357. </div>
  358. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  359. <td align="left"><p><small>Last revised: December 10, 2019 at 00:21:49 GMT</small></p></td>
  360. <td align="right"><div class="copyright-footer"></div></td>
  361. </tr></table>
  362. <hr>
  363. <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>
  364. </body>
  365. </html>