2012-06-03 03:18:40 -07:00
< html >
2012-06-03 14:29:52 +04:00
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=US-ASCII" >
2014-02-21 13:02:00 +04:00
< title > Chapter  1.  Boost.TypeIndex 3.0</ title >
2013-10-12 20:15:33 +04:00
< link rel = "stylesheet" href = "http://www.boost.org/doc/libs/1_53_0/doc/src/boostbook.css" type = "text/css" >
2012-06-03 14:29:52 +04:00
< meta name = "generator" content = "DocBook XSL Stylesheets V1.75.2" >
2014-02-21 13:02:00 +04:00
< link rel = "home" href = "index.html" title = "Chapter 1. Boost.TypeIndex 3.0" >
2012-06-03 14:29:52 +04:00
< link rel = "next" href = "boost_typeindex/getting_started.html" title = "Getting started" >
</ head >
< body bgcolor = "white" text = "black" link = "#0000FF" vlink = "#840084" alink = "#0000FF" >
< table cellpadding = "2" width = "100%" >< tr >
2013-10-12 20:15:33 +04:00
< td valign = "top" >< img alt = "Boost C++ Libraries" width = "277" height = "86" src = "http://www.boost.org/doc/libs/1_53_0/boost.png" ></ td >
< td align = "center" >< a href = "http://www.boost.org/doc/libs/1_53_0/index.html" > Home</ a ></ td >
< td align = "center" >< a href = "http://www.boost.org/doc/libs/1_53_0/libs/libraries.htm" > Libraries</ a ></ td >
2012-06-03 14:29:52 +04:00
< 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 >
2013-10-12 20:15:33 +04:00
< td align = "center" >< a href = "http://www.boost.org/doc/libs/1_53_0/more/index.htm" > More</ a ></ td >
2012-06-03 14:29:52 +04:00
</ tr ></ table >
< hr >
2013-10-12 20:15:33 +04:00
< div class = "spirit-nav" >< a accesskey = "n" href = "boost_typeindex/getting_started.html" >< img src = "http://www.boost.org/doc/libs/1_53_0/doc/src/images/next.png" alt = "Next" ></ a ></ div >
2012-06-03 14:29:52 +04:00
< div class = "chapter" >
< div class = "titlepage" >< div >
< div >< h2 class = "title" >
2014-02-21 13:02:00 +04:00
< a name = "boost_typeindex" ></ a > Chapter  1.  Boost.TypeIndex 3.0</ h2 ></ div >
< div >< p class = "copyright" > Copyright © 2012-2014 Antony Polukhin</ p ></ div >
2012-06-03 14:29:52 +04:00
< div >< div class = "legalnotice" >
< a name = "boost_typeindex.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 >
< dt >< span class = "section" >< a href = "index.html#boost_typeindex.motivation" > Motivation</ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex/getting_started.html" > Getting started</ a ></ span ></ dt >
2014-02-21 13:02:00 +04:00
< dd >< dl >
< dt >< span class = "section" >< a href = "boost_typeindex/getting_started.html#boost_typeindex.getting_started.how_to_use" > How to use</ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex/getting_started.html#boost_typeindex.getting_started.example_with_boost_any" > Example
with Boost.Any</ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex/getting_started.html#boost_typeindex.getting_started.example_with_boost_variant" > Example
with Boost.Variant</ a ></ span ></ dt >
</ dl ></ dd >
< dt >< span class = "section" >< a href = "boost_typeindex/how_it_works.html" > How it works</ a ></ span ></ dt >
2012-06-03 14:29:52 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/examples.html" > Examples</ a ></ span ></ dt >
2013-10-15 15:05:49 +04:00
< dd >< dl >
2013-10-29 16:24:39 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/examples.html#boost_typeindex.examples.getting_human_readable_and_mangl" > Getting
2013-10-15 15:05:49 +04:00
human readable and mangled type names</ a ></ span ></ dt >
2013-10-29 16:24:39 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/examples.html#boost_typeindex.examples.storing_information_about_a_type" > Storing
2013-10-15 15:05:49 +04:00
information about a type in container </ a ></ span ></ dt >
2013-10-29 16:24:39 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/examples.html#boost_typeindex.examples.getting_through_the_inheritance_" > Getting
2013-10-15 15:05:49 +04:00
through the inheritance to receive a real type name </ a ></ span ></ dt >
2013-10-29 16:24:39 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/examples.html#boost_typeindex.examples.exact_type_match_storing_type_wi" > Exact
2013-10-15 15:05:49 +04:00
type match: storing type with const, volatile and reference </ a ></ span ></ dt >
</ dl ></ dd >
2012-06-03 19:44:44 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex_header_reference.html" > Boost.TypeIndex Header Reference</ a ></ span ></ dt >
2013-10-12 20:15:33 +04:00
< dd >< dl >
< dt >< span class = "section" >< a href = "boost_typeindex_header_reference.html#header.boost.type_index_hpp" > Header < boost/type_index.hpp> </ a ></ span ></ dt >
2014-02-21 13:02:00 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex_header_reference.html#header.boost.type_index.ctti_register_class_hpp" > Header < boost/type_index/ctti_register_class.hpp> </ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex_header_reference.html#header.boost.type_index.ctti_type_index_hpp" > Header < boost/type_index/ctti_type_index.hpp> </ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex_header_reference.html#header.boost.type_index.stl_register_class_hpp" > Header < boost/type_index/stl_register_class.hpp> </ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex_header_reference.html#header.boost.type_index.stl_type_index_hpp" > Header < boost/type_index/stl_type_index.hpp> </ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex_header_reference.html#header.boost.type_index.type_index_facade_hpp" > Header < boost/type_index/type_index_facade.hpp> </ a ></ span ></ dt >
</ dl ></ dd >
< dt >< span class = "section" >< a href = "boost_typeindex/making_own_type_index.html" > Making own type_index</ a ></ span ></ dt >
< dd >< dl >
< dt >< span class = "section" >< a href = "boost_typeindex/making_own_type_index.html#boost_typeindex.making_own_type_index.basics" > Basics</ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex/making_own_type_index.html#boost_typeindex.making_own_type_index.getting_type_infos_at_runtime" > Getting
type infos at runtime</ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex/making_own_type_index.html#boost_typeindex.making_own_type_index.using_new_type_infos_all_around_" > Using
new type infos all around the code</ a ></ span ></ dt >
2013-10-12 20:15:33 +04:00
</ dl ></ dd >
2013-10-17 11:54:24 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/space_and_performance.html" > Space and Performance</ a ></ span ></ dt >
< dt >< span class = "section" >< a href = "boost_typeindex/code_bloat.html" > Code bloat</ a ></ span ></ dt >
2012-08-14 16:06:35 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/compiler_support.html" > Compiler support</ a ></ span ></ dt >
2013-10-29 16:24:39 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/mixing_sources_with_rtti_on_and_.html" > Mixing
2013-10-22 17:02:29 +04:00
sources with RTTI on and RTTI off</ a ></ span ></ dt >
2013-11-06 11:27:56 +04:00
< dt >< span class = "section" >< a href = "boost_typeindex/acknowledgements.html" > Acknowledgements</ a ></ span ></ dt >
2012-06-03 14:29:52 +04:00
</ dl >
</ div >
2013-10-12 20:15:33 +04:00
< div class = "section" >
2012-06-03 14:29:52 +04:00
< div class = "titlepage" >< div >< div >< h2 class = "title" style = "clear: both" >
< a name = "boost_typeindex.motivation" ></ a >< a class = "link" href = "index.html#boost_typeindex.motivation" title = "Motivation" > Motivation</ a >
</ h2 ></ div ></ div ></ div >
< p >
2013-10-16 17:27:27 +04:00
Sometimes getting and storing information about a type at runtime is required.
For such cases a construction like < code class = "computeroutput" >< span class = "special" > & </ 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 >
2012-07-18 22:50:01 +04:00
is usually used. And that is the point, where problems start:
2012-06-03 14:29:52 +04:00
</ p >
2012-06-03 14:51:43 +04:00
< div class = "itemizedlist" >< ul class = "itemizedlist" type = "disc" >
< li class = "listitem" >
< code class = "computeroutput" >< span class = "keyword" > typeid</ span >< span class = "special" > (</ span >< span class = "identifier" > T</ span >< span class = "special" > )</ span ></ code > and
< code class = "computeroutput" >< span class = "identifier" > std</ span >< span class = "special" > ::</ span >< span class = "identifier" > type_index</ span ></ code > require Run Time Type Info
(RTTI)
</ li >
< li class = "listitem" >
2012-07-09 22:13:50 +04:00
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 >
strip const, volatile and references from type, while others don't
2012-06-03 14:51:43 +04:00
</ li >
< li class = "listitem" >
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 >
2012-07-09 22:13:50 +04:00
objects across shared libraries
2012-06-03 14:51:43 +04:00
</ li >
< li class = "listitem" >
2013-10-17 11:54:24 +04:00
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 >
2012-06-03 14:51:43 +04:00
</ li >
< li class = "listitem" >
no easy way to store type info without stripping const, volatile and references
</ li >
< li class = "listitem" >
2012-07-09 22:13:50 +04:00
no nice and portable way to get human readable type names
2012-06-03 14:51:43 +04:00
</ li >
2014-02-21 13:02:00 +04:00
< li class = "listitem" >
no way to easily make your own type info class
</ li >
2012-06-03 14:51:43 +04:00
</ ul ></ div >
2012-06-03 14:29:52 +04:00
< p >
2013-10-29 16:24:39 +04:00
Boost.TypeIndex library was designed to work around all those issues.
2012-06-03 14:29:52 +04:00
</ p >
2012-06-26 21:20:15 +04:00
< div class = "note" >< table border = "0" summary = "Note" >
< tr >
2013-10-12 20:15:33 +04:00
< td rowspan = "2" align = "center" valign = "top" width = "25" >< img alt = "[Note]" src = "http://www.boost.org/doc/libs/1_53_0/doc/src/images/note.png" ></ td >
2012-06-26 21:20:15 +04:00
< th align = "left" > Note</ th >
</ tr >
< tr >< td align = "left" valign = "top" >< p >
2012-07-09 22:13:50 +04:00
< code class = "computeroutput" >< span class = "identifier" > T</ span ></ code > means type here. Think
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" > < </ span >< span class = "keyword" > class</ span > < span class = "identifier" > T</ span >< span class = "special" > > </ span ></ code >
2012-06-26 21:20:15 +04:00
</ p ></ td ></ tr >
</ table ></ div >
2012-06-03 15:18:14 +04:00
< div class = "warning" >< table border = "0" summary = "Warning" >
< tr >
2013-10-12 20:15:33 +04:00
< td rowspan = "2" align = "center" valign = "top" width = "25" >< img alt = "[Warning]" src = "http://www.boost.org/doc/libs/1_53_0/doc/src/images/warning.png" ></ td >
2012-06-03 15:18:14 +04:00
< th align = "left" > Warning</ th >
</ tr >
< tr >< td align = "left" valign = "top" >< p >
2014-02-21 13:02:00 +04:00
Version 3.0 of this library is waitning for Boost mini-review.
2012-06-03 15:18:14 +04:00
</ p ></ td ></ tr >
</ table ></ div >
2012-06-03 14:29:52 +04:00
</ div >
</ div >
< table xmlns:rev = "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width = "100%" >< tr >
2014-02-21 17:55:15 +04:00
< td align = "left" >< p >< small > Last revised: February 21, 2014 at 13:52:51 GMT</ small ></ p ></ td >
2012-06-03 14:29:52 +04:00
< td align = "right" >< div class = "copyright-footer" ></ div ></ td >
</ tr ></ table >
< hr >
2013-10-12 20:15:33 +04:00
< div class = "spirit-nav" >< a accesskey = "n" href = "boost_typeindex/getting_started.html" >< img src = "http://www.boost.org/doc/libs/1_53_0/doc/src/images/next.png" alt = "Next" ></ a ></ div >
2012-06-03 14:29:52 +04:00
</ body >
</ html >