Imported Upstream version 1.64.0
[platform/upstream/boost.git] / doc / html / boost_typeindex.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Chapter&#160;41.&#160;Boost.TypeIndex 4.1</title>
6 <link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="libraries.html" title="Part&#160;I.&#160;The Boost C++ Libraries (BoostBook Subset)">
10 <link rel="prev" href="boost_typeerasure/related.html" title="Related Work">
11 <link rel="next" href="boost_typeindex/getting_started.html" title="Getting started">
12 </head>
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
16 <td align="center"><a href="../../index.html">Home</a></td>
17 <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../more/index.htm">More</a></td>
21 </tr></table>
22 <hr>
23 <div class="spirit-nav">
24 <a accesskey="p" href="boost_typeerasure/related.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_typeindex/getting_started.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
25 </div>
26 <div class="chapter">
27 <div class="titlepage"><div>
28 <div><h2 class="title">
29 <a name="boost_typeindex"></a>Chapter&#160;41.&#160;Boost.TypeIndex 4.1</h2></div>
30 <div><p class="copyright">Copyright &#169; 2012-2016 Antony Polukhin</p></div>
31 <div><div class="legalnotice">
32 <a name="boost_typeindex.legal"></a><p>
33         Distributed under the Boost Software License, Version 1.0. (See accompanying
34         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>)
35       </p>
36 </div></div>
37 </div></div>
38 <div class="toc">
39 <p><b>Table of Contents</b></p>
40 <dl class="toc">
41 <dt><span class="section"><a href="boost_typeindex.html#boost_typeindex.motivation">Motivation</a></span></dt>
42 <dt><span class="section"><a href="boost_typeindex/getting_started.html">Getting started</a></span></dt>
43 <dd><dl>
44 <dt><span class="section"><a href="boost_typeindex/getting_started.html#boost_typeindex.getting_started.how_to_use">How to use</a></span></dt>
45 <dt><span class="section"><a href="boost_typeindex/getting_started.html#boost_typeindex.getting_started.example_with_boost_any">Example
46       with Boost.Any</a></span></dt>
47 <dt><span class="section"><a href="boost_typeindex/getting_started.html#boost_typeindex.getting_started.example_with_boost_variant">Example
48       with Boost.Variant</a></span></dt>
49 </dl></dd>
50 <dt><span class="section"><a href="boost_typeindex/config.html">Configuring and building the library</a></span></dt>
51 <dt><span class="section"><a href="boost_typeindex/how_it_works.html">How it works</a></span></dt>
52 <dt><span class="section"><a href="boost_typeindex/examples.html">Examples</a></span></dt>
53 <dd><dl>
54 <dt><span class="section"><a href="boost_typeindex/examples.html#boost_typeindex.examples.getting_human_readable_and_mangl">Getting
55       human readable and mangled type names</a></span></dt>
56 <dt><span class="section"><a href="boost_typeindex/examples.html#boost_typeindex.examples.storing_information_about_a_type">Storing
57       information about a type in container </a></span></dt>
58 <dt><span class="section"><a href="boost_typeindex/examples.html#boost_typeindex.examples.getting_through_the_inheritance_">Getting
59       through the inheritance to receive a real type name </a></span></dt>
60 <dt><span class="section"><a href="boost_typeindex/examples.html#boost_typeindex.examples.using_runtime_cast_where_rtti_is">Using
61       runtime_cast where RTTI is unavailable or undesirable </a></span></dt>
62 <dt><span class="section"><a href="boost_typeindex/examples.html#boost_typeindex.examples.exact_type_matching_storing_type">Exact
63       type matching: storing type with const, volatile and reference qualifiers</a></span></dt>
64 <dt><span class="section"><a href="boost_typeindex/examples.html#boost_typeindex.examples.table_of_raw_name_and_pretty_nam">Table
65       of raw_name() and pretty_name() outputs with and without RTTI </a></span></dt>
66 <dt><span class="section"><a href="boost_typeindex/examples.html#boost_typeindex.examples.c_14_checking_namespace_at_compi">C++14:
67       Checking namespace at compile time </a></span></dt>
68 <dt><span class="section"><a href="boost_typeindex/examples.html#boost_typeindex.examples.c_14_checking_lexigraphical_orde">C++14:
69       Checking lexigraphical order of provided types </a></span></dt>
70 </dl></dd>
71 <dt><span class="section"><a href="boost_typeindex_header_reference.html">Boost.TypeIndex Header Reference</a></span></dt>
72 <dd><dl>
73 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index_hpp">Header &lt;boost/type_index.hpp&gt;</a></span></dt>
74 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.ctti_type_index_hpp">Header &lt;boost/type_index/ctti_type_index.hpp&gt;</a></span></dt>
75 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.runtime_cast_hpp">Header &lt;boost/type_index/runtime_cast.hpp&gt;</a></span></dt>
76 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.runtime_cast.boost_shared_ptr_cast_hpp">Header &lt;boost/type_index/runtime_cast/boost_shared_ptr_cast.hpp&gt;</a></span></dt>
77 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.runtime_cast.pointer_cast_hpp">Header &lt;boost/type_index/runtime_cast/pointer_cast.hpp&gt;</a></span></dt>
78 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.runtime_cast.reference_cast_hpp">Header &lt;boost/type_index/runtime_cast/reference_cast.hpp&gt;</a></span></dt>
79 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.runtime_cast.register_runtime_class_hpp">Header &lt;boost/type_index/runtime_cast/register_runtime_class.hpp&gt;</a></span></dt>
80 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.runtime_cast.std_shared_ptr_cast_hpp">Header &lt;boost/type_index/runtime_cast/std_shared_ptr_cast.hpp&gt;</a></span></dt>
81 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.stl_type_index_hpp">Header &lt;boost/type_index/stl_type_index.hpp&gt;</a></span></dt>
82 <dt><span class="section"><a href="boost_typeindex_header_reference.html#header.boost.type_index.type_index_facade_hpp">Header &lt;boost/type_index/type_index_facade.hpp&gt;</a></span></dt>
83 </dl></dd>
84 <dt><span class="section"><a href="boost_typeindex/making_a_custom_type_index.html">Making a custom
85     type_index</a></span></dt>
86 <dd><dl>
87 <dt><span class="section"><a href="boost_typeindex/making_a_custom_type_index.html#boost_typeindex.making_a_custom_type_index.basics">Basics</a></span></dt>
88 <dt><span class="section"><a href="boost_typeindex/making_a_custom_type_index.html#boost_typeindex.making_a_custom_type_index.getting_type_infos_at_runtime">Getting
89       type infos at runtime</a></span></dt>
90 <dt><span class="section"><a href="boost_typeindex/making_a_custom_type_index.html#boost_typeindex.making_a_custom_type_index.using_new_type_infos_all_around_">Using
91       new type infos all around the code</a></span></dt>
92 </dl></dd>
93 <dt><span class="section"><a href="boost_typeindex/space_and_performance.html">Space and Performance</a></span></dt>
94 <dt><span class="section"><a href="boost_typeindex/code_bloat.html">Code bloat</a></span></dt>
95 <dt><span class="section"><a href="boost_typeindex/rtti_emulation_limitations.html">RTTI emulation
96     limitations</a></span></dt>
97 <dd><dl>
98 <dt><span class="section"><a href="boost_typeindex/rtti_emulation_limitations.html#boost_typeindex.rtti_emulation_limitations.define_the_boost_type_index_func">Define
99       the BOOST_TYPE_INDEX_FUNCTION_SIGNATURE macro</a></span></dt>
100 <dt><span class="section"><a href="boost_typeindex/rtti_emulation_limitations.html#boost_typeindex.rtti_emulation_limitations.fixing_pretty_name_output">Fixing
101       pretty_name() output</a></span></dt>
102 </dl></dd>
103 <dt><span class="section"><a href="boost_typeindex/mixing_sources_with_rtti_on_and_.html">Mixing
104     sources with RTTI on and RTTI off</a></span></dt>
105 <dt><span class="section"><a href="boost_typeindex/acknowledgements.html">Acknowledgements</a></span></dt>
106 </dl>
107 </div>
108 <div class="section">
109 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
110 <a name="boost_typeindex.motivation"></a><a class="link" href="boost_typeindex.html#boost_typeindex.motivation" title="Motivation">Motivation</a>
111 </h2></div></div></div>
112 <p>
113       Sometimes getting and storing information about a type at runtime is required.
114       For such cases a construction like <code class="computeroutput"><span class="special">&amp;</span><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code> or C++11 class <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">type_index</span></code>
115       is usually used, which is where problems start:
116     </p>
117 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
118 <li class="listitem">
119           <code class="computeroutput"><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code> and
120           <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">type_index</span></code> require Run Time Type Info
121           (RTTI)
122         </li>
123 <li class="listitem">
124           some implementations of <code class="computeroutput"><span class="keyword">typeid</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code>
125           erroneously do not strip const, volatile and references from type
126         </li>
127 <li class="listitem">
128           some compilers have bugs and do not correctly compare <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">type_info</span></code>
129           objects across shared libraries
130         </li>
131 <li class="listitem">
132           only a few implementations of Standard Library currently provide <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">type_index</span></code>
133         </li>
134 <li class="listitem">
135           no easy way to store type info without stripping const, volatile and references
136         </li>
137 <li class="listitem">
138           no nice and portable way to get human readable type names
139         </li>
140 <li class="listitem">
141           no way to easily make your own type info class
142         </li>
143 </ul></div>
144 <p>
145       Boost.TypeIndex library was designed to work around all those issues.
146     </p>
147 <div class="note"><table border="0" summary="Note">
148 <tr>
149 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../doc/src/images/note.png"></td>
150 <th align="left">Note</th>
151 </tr>
152 <tr><td align="left" valign="top"><p>
153         <code class="computeroutput"><span class="identifier">T</span></code> means type here. Think
154         of it as of <code class="computeroutput"><span class="identifier">T</span></code> in <code class="computeroutput"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span></code>
155       </p></td></tr>
156 </table></div>
157 </div>
158 </div>
159 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
160 <td align="left"><p><small>Last revised: April 17, 2017 at 02:30:57 GMT</small></p></td>
161 <td align="right"><div class="copyright-footer"></div></td>
162 </tr></table>
163 <hr>
164 <div class="spirit-nav">
165 <a accesskey="p" href="boost_typeerasure/related.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_typeindex/getting_started.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
166 </div>
167 </body>
168 </html>