diff options
Diffstat (limited to 'doc/html/intrusive/obtaining_same_type_reducing_space.html')
-rwxr-xr-x | doc/html/intrusive/obtaining_same_type_reducing_space.html | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/doc/html/intrusive/obtaining_same_type_reducing_space.html b/doc/html/intrusive/obtaining_same_type_reducing_space.html new file mode 100755 index 0000000000..10e8de738a --- /dev/null +++ b/doc/html/intrusive/obtaining_same_type_reducing_space.html @@ -0,0 +1,100 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Obtaining the same types and reducing symbol length</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="thread_safety.html" title="Thread safety guarantees"> +<link rel="next" href="design_notes.html" title="Design Notes"> +</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="p" href="thread_safety.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="design_notes.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.obtaining_same_type_reducing_space"></a><a class="link" href="obtaining_same_type_reducing_space.html" title="Obtaining the same types and reducing symbol length">Obtaining + the same types and reducing symbol length</a> +</h2></div></div></div> +<p> + The flexible option specification mechanism used by <span class="bold"><strong>Boost.Intrusive</strong></span> + for hooks and containers has a couple of downsides: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + If a user specifies the same options in different order or specifies some + options and leaves the rest as defaults, the type of the created container/hook + will be different. Sometimes this is annoying, because two programmers + specifying the same options might end up with incompatible types. For example, + the following two lists, although using the same options, do not have the + same type: + </li></ul></div> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//Explicitly specify constant-time size and size type</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">>,</span> <span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span> <span class="identifier">List1</span><span class="special">;</span> + +<span class="comment">//Implicitly specify constant-time size and size type</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">List2</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + Option specifiers lead to long template symbols for classes and functions. + Option specifiers themselves are verbose and without variadic templates, + several default template parameters are assigned for non-specified options. + Object and debugging information files can grow and compilation times may + suffer if long names are produced. + </li></ul></div> +<p> + To solve these issues <span class="bold"><strong>Boost.Intrusive</strong></span> offers + some helper metafunctions that reduce symbol lengths and create the same type + if the same options (either explicitly or implicitly) are used. These also + improve compilation times. All containers and hooks have their respective + <code class="computeroutput"><span class="identifier">make_xxx</span></code> versions. The previously + shown example can be rewritten like this to obtain the same list type: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + + <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + + <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + + <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + + <span class="comment">//Explicitly specify constant-time size and size type</span> + <span class="keyword">typedef</span> <span class="identifier">make_list</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">>,</span> <span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">List1</span><span class="special">;</span> + + <span class="comment">//Implicitly specify constant-time size and size type</span> + <span class="keyword">typedef</span> <span class="identifier">make_list</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">List2</span><span class="special">;</span> +</pre> +<p> + Produced symbol lengths and compilation times will usually be shorter and object/debug + files smaller. If you are concerned with file sizes and compilation times, + this option is your best choice. + </p> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<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></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="thread_safety.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="design_notes.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> |