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>Struct template pointer_traits</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.pointer_traits_hpp" title="Header <boost/intrusive/pointer_traits.hpp>"> 10<link rel="prev" href="pointer__idm45020921370224.html" title="Struct template pointer_rebinder<Ptr< A, An... >, U, 0u>"> 11<link rel="next" href="pointer__idm45020921322000.html" title="Struct template pointer_traits<T *>"> 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="pointer__idm45020921370224.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../intrusive/reference.html#header.boost.intrusive.pointer_traits_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="pointer__idm45020921322000.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="boost.intrusive.pointer_traits"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Struct template pointer_traits</span></h2> 30<p>boost::intrusive::pointer_traits</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.pointer_traits_hpp" title="Header <boost/intrusive/pointer_traits.hpp>">boost/intrusive/pointer_traits.hpp</a>> 34 35</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Ptr<span class="special">></span> 36<span class="keyword">struct</span> <a class="link" href="pointer_traits.html" title="Struct template pointer_traits">pointer_traits</a> <span class="special">{</span> 37 <span class="comment">// <a class="link" href="pointer_traits.html#boost.intrusive.pointer_traitstypes">types</a></span> 38 <span class="keyword">typedef</span> <span class="identifier">Ptr</span> <a class="link" href="pointer_traits.html#boost.intrusive.pointer_traits.pointer"><span class="identifier">pointer</span></a><span class="special">;</span> 39 <span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a class="link" href="pointer_traits.html#boost.intrusive.pointer_traits.element_type"><span class="identifier">element_type</span></a><span class="special">;</span> 40 <span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a class="link" href="pointer_traits.html#boost.intrusive.pointer_traits.difference_type"><span class="identifier">difference_type</span></a><span class="special">;</span> 41 <span class="keyword">typedef</span> <span class="identifier">unspecified</span> <a class="link" href="pointer_traits.html#boost.intrusive.pointer_traits.rebind"><span class="identifier">rebind</span></a><span class="special">;</span> 42 <span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a class="link" href="pointer_traits.html#boost.intrusive.pointer_traits.reference"><span class="identifier">reference</span></a><span class="special">;</span> 43 44 <span class="comment">// <a class="link" href="pointer_traits.html#idm45020921346544-bb">public static functions</a></span> 45 <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pointer_traits.html#idm45020921345984-bb"><span class="identifier">pointer_to</span></a><span class="special">(</span><span class="identifier">reference</span><span class="special">)</span><span class="special">;</span> 46 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> UPtr<span class="special">></span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pointer_traits.html#idm45020921340736-bb"><span class="identifier">static_cast_from</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 47 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> UPtr<span class="special">></span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pointer_traits.html#idm45020921334688-bb"><span class="identifier">const_cast_from</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 48 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> UPtr<span class="special">></span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pointer_traits.html#idm45020921328640-bb"><span class="identifier">dynamic_cast_from</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 49<span class="special">}</span><span class="special">;</span></pre></div> 50<div class="refsect1"> 51<a name="id-1.3.20.42.26.3.4"></a><h2>Description</h2> 52<p><a class="link" href="pointer_traits.html" title="Struct template pointer_traits">pointer_traits</a> is the implementation of C++11 std::pointer_traits class with some extensions like castings.</p> 53<p><a class="link" href="pointer_traits.html" title="Struct template pointer_traits">pointer_traits</a> supplies a uniform interface to certain attributes of pointer-like types.</p> 54<p><span class="bold"><strong>Note</strong></span>: When defining a custom family of pointers or references to be used with BI library, make sure the public static conversion functions accessed through the <code class="computeroutput"><a class="link" href="pointer_traits.html" title="Struct template pointer_traits">pointer_traits</a></code> interface (<code class="computeroutput">*_cast_from</code> and <code class="computeroutput">pointer_to</code>) can properly convert between const and nonconst referred member types <span class="bold"><strong>without the use of implicit constructor calls</strong></span>. It is suggested these conversions be implemented as function templates, where the template argument is the type of the object being converted from. </p> 55<div class="refsect2"> 56<a name="id-1.3.20.42.26.3.4.5"></a><h3> 57<a name="boost.intrusive.pointer_traitstypes"></a><code class="computeroutput">pointer_traits</code> 58 public 59 types</h3> 60<div class="orderedlist"><ol class="orderedlist" type="1"> 61<li class="listitem"> 62<p> 63<span class="keyword">typedef</span> <span class="identifier">Ptr</span> <a name="boost.intrusive.pointer_traits.pointer"></a><span class="identifier">pointer</span><span class="special">;</span></p> 64<p>The pointer type queried by this <a class="link" href="pointer_traits.html" title="Struct template pointer_traits">pointer_traits</a> instantiation </p> 65</li> 66<li class="listitem"> 67<p> 68<span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a name="boost.intrusive.pointer_traits.element_type"></a><span class="identifier">element_type</span><span class="special">;</span></p> 69<p>Ptr::element_type if such a type exists; otherwise, T if Ptr is a class template instantiation of the form SomePointer<T, Args>, where Args is zero or more type arguments ; otherwise , the specialization is ill-formed. </p> 70</li> 71<li class="listitem"> 72<p> 73<span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a name="boost.intrusive.pointer_traits.difference_type"></a><span class="identifier">difference_type</span><span class="special">;</span></p> 74<p>Ptr::difference_type if such a type exists; otherwise, std::ptrdiff_t. </p> 75</li> 76<li class="listitem"> 77<p> 78<span class="keyword">typedef</span> <span class="identifier">unspecified</span> <a name="boost.intrusive.pointer_traits.rebind"></a><span class="identifier">rebind</span><span class="special">;</span></p> 79<p>Ptr::rebind<U> if such a type exists; otherwise, SomePointer<U, Args> if Ptr is a class template instantiation of the form SomePointer<T, Args>, where Args is zero or more type arguments ; otherwise, the instantiation of rebind is ill-formed.</p> 80<p>For portable code for C++03 and C++11, </p> 81<pre class="programlisting"><span class="keyword">typename</span> <span class="identifier">rebind_pointer</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span><span class="special">::</span><span class="identifier">type</span></pre> 82<p> shall be used instead of rebind<span style="color: red"><underline> to obtain a pointer to U. </underline></span></p> 83</li> 84<li class="listitem"> 85<p> 86<span class="keyword">typedef</span> <span class="identifier">unspecified_type</span> <a name="boost.intrusive.pointer_traits.reference"></a><span class="identifier">reference</span><span class="special">;</span></p> 87<p>Ptr::reference if such a type exists (non-standard extension); otherwise, element_type & </p> 88</li> 89</ol></div> 90</div> 91<div class="refsect2"> 92<a name="id-1.3.20.42.26.3.4.6"></a><h3> 93<a name="idm45020921346544-bb"></a><code class="computeroutput">pointer_traits</code> public static functions</h3> 94<div class="orderedlist"><ol class="orderedlist" type="1"> 95<li class="listitem"> 96<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">pointer</span> <a name="idm45020921345984-bb"></a><span class="identifier">pointer_to</span><span class="special">(</span><span class="identifier">reference</span> r<span class="special">)</span><span class="special">;</span></pre> 97<p><span class="bold"><strong>Remark</strong></span>: If element_type is (possibly cv-qualified) void, r type is unspecified; otherwise, it is element_type &.</p> 98<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling Ptr::pointer_to(reference). Non-standard extension: If such function does not exist, returns pointer(addressof(r));</p> 99<p><span class="bold"><strong>Note</strong></span>: For non-conforming compilers only the existence of a member function called <code class="computeroutput">pointer_to</code> is checked. </p> 100</li> 101<li class="listitem"> 102<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> UPtr<span class="special">></span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="idm45020921340736-bb"></a><span class="identifier">static_cast_from</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&</span> uptr<span class="special">)</span><span class="special">;</span></pre> 103<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p> 104<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling the static template function Ptr::static_cast_from(UPpr/const UPpr &). If such function does not exist, returns pointer_to(static_cast<element_type&>(*uptr))</p> 105<p><span class="bold"><strong>Note</strong></span>: For non-conforming compilers only the existence of a member function called <code class="computeroutput">static_cast_from</code> is checked. </p> 106</li> 107<li class="listitem"> 108<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> UPtr<span class="special">></span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="idm45020921334688-bb"></a><span class="identifier">const_cast_from</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&</span> uptr<span class="special">)</span><span class="special">;</span></pre> 109<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p> 110<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling the static template function Ptr::const_cast_from<UPtr>(UPpr/const UPpr &). If such function does not exist, returns pointer_to(const_cast<element_type&>(*uptr))</p> 111<p><span class="bold"><strong>Note</strong></span>: For non-conforming compilers only the existence of a member function called <code class="computeroutput">const_cast_from</code> is checked. </p> 112</li> 113<li class="listitem"> 114<pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> UPtr<span class="special">></span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="idm45020921328640-bb"></a><span class="identifier">dynamic_cast_from</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">UPtr</span> <span class="special">&</span> uptr<span class="special">)</span><span class="special">;</span></pre> 115<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p> 116<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling the static template function Ptr::dynamic_cast_from<UPtr>(UPpr/const UPpr &). If such function does not exist, returns pointer_to(<span class="emphasis"><em>dynamic_cast<element_type</em></span>>(&*uptr))</p> 117<p><span class="bold"><strong>Note</strong></span>: For non-conforming compilers only the existence of a member function called <code class="computeroutput">dynamic_cast_from</code> is checked. </p> 118</li> 119</ol></div> 120</div> 121</div> 122</div> 123<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 124<td align="left"></td> 125<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2015 Ion Gaztanaga<p> 126 Distributed under the Boost Software License, Version 1.0. (See accompanying 127 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>) 128 </p> 129</div></td> 130</tr></table> 131<hr> 132<div class="spirit-nav"> 133<a accesskey="p" href="pointer__idm45020921370224.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../intrusive/reference.html#header.boost.intrusive.pointer_traits_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="pointer__idm45020921322000.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 134</div> 135</body> 136</html> 137