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=UTF-8"> 5<title>Class template slist_member_hook</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="../../intrusive/reference.html#header.boost.intrusive.slist_hook_hpp" title="Header <boost/intrusive/slist_hook.hpp>"> 10<link rel="prev" href="slist_base_hook.html" title="Class template slist_base_hook"> 11<link rel="next" href="make_splay_multiset.html" title="Struct template make_splay_multiset"> 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="slist_base_hook.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../intrusive/reference.html#header.boost.intrusive.slist_hook_hpp"><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="make_splay_multiset.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="boost.intrusive.slist_member_hook"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Class template slist_member_hook</span></h2> 30<p>boost::intrusive::slist_member_hook</p> 31</div> 32<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 33<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../intrusive/reference.html#header.boost.intrusive.slist_hook_hpp" title="Header <boost/intrusive/slist_hook.hpp>">boost/intrusive/slist_hook.hpp</a>> 34 35</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="special">...</span> Options<span class="special">></span> 36<span class="keyword">class</span> <a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">make_slist_member_hook</span><span class="special">::</span><span class="identifier">type</span><span class="special"><</span> <span class="identifier">O1</span><span class="special">,</span> <span class="identifier">O2</span><span class="special">,</span> <span class="identifier">O3</span> <span class="special">></span> <span class="special">{</span> 37<span class="keyword">public</span><span class="special">:</span> 38 <span class="comment">// <a class="link" href="slist_member_hook.html#boost.intrusive.slist_member_hookconstruct-copy-destruct">construct/copy/destruct</a></span> 39 <a class="link" href="slist_member_hook.html#idm45020916237296-bb"><span class="identifier">slist_member_hook</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> 40 <a class="link" href="slist_member_hook.html#idm45020916233520-bb"><span class="identifier">slist_member_hook</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 41 <a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">&</span> <a class="link" href="slist_member_hook.html#idm45020916227152-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 42 <a class="link" href="slist_member_hook.html#idm45020916221856-bb"><span class="special">~</span><span class="identifier">slist_member_hook</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> 43 44 <span class="comment">// <a class="link" href="slist_member_hook.html#idm45020916253968-bb">public member functions</a></span> 45 <span class="keyword">void</span> <a class="link" href="slist_member_hook.html#idm45020916253408-bb"><span class="identifier">swap_nodes</span></a><span class="special">(</span><a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 46 <span class="keyword">bool</span> <a class="link" href="slist_member_hook.html#idm45020916248400-bb"><span class="identifier">is_linked</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 47 <span class="keyword">void</span> <a class="link" href="slist_member_hook.html#idm45020916241376-bb"><span class="identifier">unlink</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> 48<span class="special">}</span><span class="special">;</span></pre></div> 49<div class="refsect1"> 50<a name="id-1.3.20.42.36.6.4"></a><h2>Description</h2> 51<p>Put a public data member <a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> in order to store objects of this class in an list. <a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> holds the data necessary for maintaining the list and provides an appropriate <a class="link" href="value_traits.html" title="Struct template value_traits">value_traits</a> class for list.</p> 52<p>The hook admits the following options: <code class="computeroutput">void_pointer<></code> and <code class="computeroutput">link_mode<></code>.</p> 53<p><code class="computeroutput">link_mode<></code> will specify the linking mode of the hook (<code class="computeroutput">normal_link</code>, <code class="computeroutput">auto_unlink</code> or <code class="computeroutput">safe_link</code>).</p> 54<p><code class="computeroutput">void_pointer<></code> is the pointer type that will be used internally in the hook and the container configured to use this hook. </p> 55<div class="refsect2"> 56<a name="id-1.3.20.42.36.6.4.6"></a><h3> 57<a name="boost.intrusive.slist_member_hookconstruct-copy-destruct"></a><code class="computeroutput">slist_member_hook</code> 58 public 59 construct/copy/destruct</h3> 60<div class="orderedlist"><ol class="orderedlist" type="1"> 61<li class="listitem"> 62<pre class="literallayout"><a name="idm45020916237296-bb"></a><span class="identifier">slist_member_hook</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre> 63<p><span class="bold"><strong>Effects</strong></span>: If <code class="computeroutput"><a class="link" href="link_mode.html" title="Struct template link_mode">link_mode</a></code> is <code class="computeroutput">auto_unlink</code> or <code class="computeroutput">safe_link</code> initializes the node to an unlinked state.</p> 64<p><span class="bold"><strong>Throws</strong></span>: Nothing. </p> 65</li> 66<li class="listitem"> 67<pre class="literallayout"><a name="idm45020916233520-bb"></a><span class="identifier">slist_member_hook</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">&</span><span class="special">)</span><span class="special">;</span></pre> 68<p><span class="bold"><strong>Effects</strong></span>: If <code class="computeroutput"><a class="link" href="link_mode.html" title="Struct template link_mode">link_mode</a></code> is <code class="computeroutput">auto_unlink</code> or <code class="computeroutput">safe_link</code> initializes the node to an unlinked state. The argument is ignored.</p> 69<p><span class="bold"><strong>Throws</strong></span>: Nothing.</p> 70<p><span class="bold"><strong>Rationale</strong></span>: Providing a copy-constructor makes classes using the hook STL-compliant without forcing the user to do some additional work. <code class="computeroutput">swap</code> can be used to emulate move-semantics. </p> 71</li> 72<li class="listitem"> 73<pre class="literallayout"><a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">&</span> <a name="idm45020916227152-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">&</span><span class="special">)</span><span class="special">;</span></pre> 74<p><span class="bold"><strong>Effects</strong></span>: Empty function. The argument is ignored.</p> 75<p><span class="bold"><strong>Throws</strong></span>: Nothing.</p> 76<p><span class="bold"><strong>Rationale</strong></span>: Providing an assignment operator makes classes using the hook STL-compliant without forcing the user to do some additional work. <code class="computeroutput">swap</code> can be used to emulate move-semantics. </p> 77</li> 78<li class="listitem"> 79<pre class="literallayout"><a name="idm45020916221856-bb"></a><span class="special">~</span><span class="identifier">slist_member_hook</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre> 80<p><span class="bold"><strong>Effects</strong></span>: If <code class="computeroutput"><a class="link" href="link_mode.html" title="Struct template link_mode">link_mode</a></code> is <code class="computeroutput">normal_link</code>, the destructor does nothing (ie. no code is generated). If <code class="computeroutput"><a class="link" href="link_mode.html" title="Struct template link_mode">link_mode</a></code> is <code class="computeroutput">safe_link</code> and the object is stored in an slist an assertion is raised. If <code class="computeroutput"><a class="link" href="link_mode.html" title="Struct template link_mode">link_mode</a></code> is <code class="computeroutput">auto_unlink</code> and <code class="computeroutput">is_linked()</code> is true, the node is unlinked.</p> 81<p><span class="bold"><strong>Throws</strong></span>: Nothing. </p> 82</li> 83</ol></div> 84</div> 85<div class="refsect2"> 86<a name="id-1.3.20.42.36.6.4.7"></a><h3> 87<a name="idm45020916253968-bb"></a><code class="computeroutput">slist_member_hook</code> public member functions</h3> 88<div class="orderedlist"><ol class="orderedlist" type="1"> 89<li class="listitem"> 90<pre class="literallayout"><span class="keyword">void</span> <a name="idm45020916253408-bb"></a><span class="identifier">swap_nodes</span><span class="special">(</span><a class="link" href="slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a> <span class="special">&</span> other<span class="special">)</span><span class="special">;</span></pre> 91<p><span class="bold"><strong>Effects</strong></span>: Swapping two nodes swaps the position of the elements related to those nodes in one or two containers. That is, if the node this is part of the element e1, the node x is part of the element e2 and both elements are included in the containers s1 and s2, then after the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 at the position of e1. If one element is not in a container, then after the swap-operation the other element is not in a container. Iterators to e1 and e2 related to those nodes are invalidated.</p> 92<p><span class="bold"><strong>Complexity</strong></span>: Constant</p> 93<p><span class="bold"><strong>Throws</strong></span>: Nothing. </p> 94</li> 95<li class="listitem"> 96<pre class="literallayout"><span class="keyword">bool</span> <a name="idm45020916248400-bb"></a><span class="identifier">is_linked</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre> 97<p><span class="bold"><strong>Precondition</strong></span>: <code class="computeroutput"><a class="link" href="link_mode.html" title="Struct template link_mode">link_mode</a></code> must be <code class="computeroutput">safe_link</code> or <code class="computeroutput">auto_unlink</code>.</p> 98<p><span class="bold"><strong>Returns</strong></span>: true, if the node belongs to a container, false otherwise. This function can be used to test whether <code class="computeroutput">slist::iterator_to</code> will return a valid iterator.</p> 99<p><span class="bold"><strong>Note</strong></span>: If this member is called when the value is inserted in a slist with the option linear<true>, this function will return "false" for the last element, as it is not linked to anything (the next element is null), so use with care.</p> 100<p><span class="bold"><strong>Complexity</strong></span>: Constant </p> 101</li> 102<li class="listitem"> 103<pre class="literallayout"><span class="keyword">void</span> <a name="idm45020916241376-bb"></a><span class="identifier">unlink</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre> 104<p><span class="bold"><strong>Effects</strong></span>: Removes the node if it's inserted in a container. This function is only allowed if <code class="computeroutput"><a class="link" href="link_mode.html" title="Struct template link_mode">link_mode</a></code> is <code class="computeroutput">auto_unlink</code>.</p> 105<p><span class="bold"><strong>Throws</strong></span>: Nothing. </p> 106</li> 107</ol></div> 108</div> 109</div> 110</div> 111<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 112<td align="left"></td> 113<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2015 Ion Gaztanaga<p> 114 Distributed under the Boost Software License, Version 1.0. (See accompanying 115 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>) 116 </p> 117</div></td> 118</tr></table> 119<hr> 120<div class="spirit-nav"> 121<a accesskey="p" href="slist_base_hook.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../intrusive/reference.html#header.boost.intrusive.slist_hook_hpp"><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="make_splay_multiset.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 122</div> 123</body> 124</html> 125