366 lines
18 KiB
HTML
366 lines
18 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
<title>Chapter 1. The Type Traits Introspection Library</title>
|
|
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
|
|
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
|
<link rel="home" href="index.html" title="Chapter 1. The Type Traits Introspection Library">
|
|
<link rel="next" href="the_type_traits_introspection_library/tti_reason.html" title="Why the TTI Library ?">
|
|
</head>
|
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
<table cellpadding="2" width="100%"><tr>
|
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
|
|
<td align="center"><a href="../../../../index.html">Home</a></td>
|
|
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
|
|
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
|
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
|
<td align="center"><a href="../../../../more/index.htm">More</a></td>
|
|
</tr></table>
|
|
<hr>
|
|
<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>
|
|
<div class="chapter">
|
|
<div class="titlepage"><div>
|
|
<div><h2 class="title">
|
|
<a name="tti"></a>Chapter 1. The Type Traits Introspection Library</h2></div>
|
|
<div><div class="author"><h3 class="author">
|
|
<span class="firstname">Edward</span> <span class="surname">Diener</span>
|
|
</h3></div></div>
|
|
<div><p class="copyright">Copyright © 2011-2013 Tropic Software
|
|
East Inc</p></div>
|
|
<div><div class="legalnotice">
|
|
<a name="tti.legal"></a><p>
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
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>)
|
|
</p>
|
|
</div></div>
|
|
</div></div>
|
|
<div class="toc">
|
|
<p><b>Table of Contents</b></p>
|
|
<dl class="toc">
|
|
<dt><span class="section"><a href="index.html#the_type_traits_introspection_library.tti_intro">Introduction</a></span></dt>
|
|
<dd><dl><dt><span class="section"><a href="index.html#the_type_traits_introspection_library.tti_intro.tti_headers">Header
|
|
Files</a></span></dt></dl></dd>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_reason.html">Why the
|
|
TTI Library ?</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_terminology.html">Terminology</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_functionality.html">General
|
|
Functionality</a></span></dt>
|
|
<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
|
|
metafunction name generation considerations</a></span></dt></dl></dd>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail.html">Macro
|
|
Metafunctions</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_type.html">Introspecting
|
|
an inner type</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_template.html">Introspecting
|
|
an inner class template</a></span></dt>
|
|
<dd><dl>
|
|
<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
|
|
the BOOST_TTI_HAS_TEMPLATE macro</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_template/tti_detail_has_template_metafunction.html">Using
|
|
the has_template_(xxx) metafunction</a></span></dt>
|
|
</dl></dd>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_member_data.html">Introspecting
|
|
member data</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_member_function.html">Introspecting
|
|
member function</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_static_member_data.html">Introspecting
|
|
static member data</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_static_member_function.html">Introspecting
|
|
static member function</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_data.html">Introspecting
|
|
inner data</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_detail_has_function.html">Introspecting
|
|
an inner function</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_nested_type.html">Nested
|
|
Types</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_func_sig.html">Nested
|
|
Types and Function Signatures</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_enclosing_type.html">Enclosing
|
|
Type</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_usingMM.html">An example
|
|
using the Macro Metafunctions</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_func_templates.html">Introspecting
|
|
Function Templates</a></span></dt>
|
|
<dt><span class="section"><a href="reference.html">Reference</a></span></dt>
|
|
<dd><dl>
|
|
<dt><span class="section"><a href="reference.html#header.boost.tti.gen.has_data_gen_hpp">Header <boost/tti/gen/has_data_gen.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<dt><span class="section"><a href="header/boost/tti/gen/namespace_gen_hpp.html">Header <boost/tti/gen/namespace_gen.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
<dt><span class="section"><a href="header/boost/tti/has_data_hpp.html">Header <boost/tti/has_data.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
<dt><span class="section"><a href="header/boost/tti/has_function_hpp.html">Header <boost/tti/has_function.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
<dt><span class="section"><a href="header/boost/tti/has_member_data_hpp.html">Header <boost/tti/has_member_data.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
<dt><span class="section"><a href="header/boost/tti/has_member_function_hpp.html">Header <boost/tti/has_member_function.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<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>
|
|
<dd><dl></dl></dd>
|
|
<dt><span class="section"><a href="header/boost/tti/has_template_hpp.html">Header <boost/tti/has_template.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
<dt><span class="section"><a href="header/boost/tti/has_type_hpp.html">Header <boost/tti/has_type.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
<dt><span class="section"><a href="header/boost/tti/member_type_hpp.html">Header <boost/tti/member_type.hpp></a></span></dt>
|
|
<dd><dl></dl></dd>
|
|
</dl></dd>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_tests.html">Testing
|
|
TTI</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_history.html">History</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_todo.html">ToDo</a></span></dt>
|
|
<dt><span class="section"><a href="the_type_traits_introspection_library/tti_acknowledgments.html">Acknowledgments</a></span></dt>
|
|
<dt><span class="section"><a href="index/s24.html">Index</a></span></dt>
|
|
</dl>
|
|
</div>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
|
<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>
|
|
</h2></div></div></div>
|
|
<div class="toc"><dl class="toc"><dt><span class="section"><a href="index.html#the_type_traits_introspection_library.tti_intro.tti_headers">Header
|
|
Files</a></span></dt></dl></div>
|
|
<p>
|
|
Welcome to the Boost Type Traits Introspection library, abbreviated TTI.
|
|
</p>
|
|
<p>
|
|
TTI is a library which provides the ability to introspect by name the elements
|
|
of a type at compile time.
|
|
</p>
|
|
<p>
|
|
TTI works through macros generating metafunctions. Metafunctions are class
|
|
templates of a particular syntax, having a nested 'type' member. So wherever
|
|
in C++ class templates can occur, TTI macros can be used. The metafunctions
|
|
generated by TTI are no different from any other metafunction as defined by
|
|
the Boost MPL library.
|
|
</p>
|
|
<p>
|
|
The metafunctions generated by TTI are used to introspect elements of a type
|
|
at compile time, always passing at minimum to each metafunction the enclosing
|
|
type being introspected.
|
|
</p>
|
|
<p>
|
|
The name of the library has been chosen because the library offers compile
|
|
time functionality on a type, similar to the Boost Type Traits library, and
|
|
because the functionality the library offers is the ability to introspect a
|
|
type about the existence of a specific element within that type.
|
|
</p>
|
|
<p>
|
|
I use the word "introspect" in a very broad sense here. Normally
|
|
computer language introspection means initially asking for information to be
|
|
returned by name, which can then further be used to introspect for more specific
|
|
information. In the TTI library one must always know and supply the name, and
|
|
use the functionality provided for the correct type of inner element to find
|
|
out if that particular named entity exists.
|
|
</p>
|
|
<p>
|
|
You may prefer the term "query" instead of "introspection"
|
|
to denote what this library does, but I use terminology based on the word "introspect"
|
|
throughout this documentation.
|
|
</p>
|
|
<p>
|
|
The functionality of the library may be summed up as:
|
|
</p>
|
|
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
|
<li class="listitem">
|
|
Provide the means to introspect a type at compile time using a set of macros.
|
|
Each macro takes the name of the type's element and generates a metafunction
|
|
which can be subsequently invoked to determine whether or not the element
|
|
exists within the type. These generated metafunctions will be called "macro
|
|
metafunctions" in the documentation.
|
|
</li>
|
|
<li class="listitem">
|
|
Provide the means to create a typedef for a type which may not exist. This
|
|
typedef type can be used as a type in the metafunctions of the library
|
|
without producing compile-time errors.
|
|
</li>
|
|
</ul></div>
|
|
<p>
|
|
The library is dependent on Boost PP, Boost MPL, Boost Type Traits, and Boost
|
|
Function Types.
|
|
</p>
|
|
<p>
|
|
The library is also dependent on the variadic macro support of the Boost PP
|
|
library if the variadic macros in the library are used.
|
|
</p>
|
|
<p>
|
|
The library is a header only library.
|
|
</p>
|
|
<p>
|
|
Since the dependencies of the library are all header only libraries, there
|
|
is no need to build a library in order to use the TTI library.
|
|
</p>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h3 class="title">
|
|
<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
|
|
Files</a>
|
|
</h3></div></div></div>
|
|
<p>
|
|
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>,
|
|
which includes all the header files in the library.
|
|
</p>
|
|
<p>
|
|
There are also separate specific header files for each of the elements to
|
|
be introspected by the library. This allows for finer-grained inclusion of
|
|
the nested elements to be introspected. These header files are:
|
|
</p>
|
|
<div class="table">
|
|
<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>
|
|
<div class="table-contents"><table class="table" summary="TTI Header Files">
|
|
<colgroup>
|
|
<col>
|
|
<col>
|
|
</colgroup>
|
|
<thead><tr>
|
|
<th>
|
|
<p>
|
|
Introspected Element
|
|
</p>
|
|
</th>
|
|
<th>
|
|
<p>
|
|
Specific Header File
|
|
</p>
|
|
</th>
|
|
</tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Type
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Class Template
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Member data
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Member function
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Static member data
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Static member function
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Data
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Function
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<p>
|
|
Member Type Creation
|
|
</p>
|
|
</td>
|
|
<td>
|
|
<p>
|
|
<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>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table></div>
|
|
</div>
|
|
<br class="table-break">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
<td align="left"><p><small>Last revised: December 14, 2017 at 00:09:43 GMT</small></p></td>
|
|
<td align="right"><div class="copyright-footer"></div></td>
|
|
</tr></table>
|
|
<hr>
|
|
<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>
|
|
</body>
|
|
</html>
|