summaryrefslogtreecommitdiff
path: root/doc/html/boost/intrusive/pointer_traits.html
blob: 18c73a1e41292633b1ccbb4d687ed1b22b1bc7a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Struct template pointer_traits</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../intrusive/reference.html#header.boost.intrusive.pointer_traits_hpp" title="Header &lt;boost/intrusive/pointer_traits.hpp&gt;">
<link rel="prev" href="pointer_rebind_idp48981792.html" title="Struct template pointer_rebinder&lt;Ptr&lt; A, An...&gt;, U, 0u&gt;">
<link rel="next" href="pointer_traits_idp49029744.html" title="Struct template pointer_traits&lt;T *&gt;">
</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="pointer_rebind_idp48981792.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_traits_idp49029744.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.intrusive.pointer_traits"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Struct template pointer_traits</span></h2>
<p>boost::intrusive::pointer_traits</p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../intrusive/reference.html#header.boost.intrusive.pointer_traits_hpp" title="Header &lt;boost/intrusive/pointer_traits.hpp&gt;">boost/intrusive/pointer_traits.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Ptr<span class="special">&gt;</span> 
<span class="keyword">struct</span> <a class="link" href="pointer_traits.html" title="Struct template pointer_traits">pointer_traits</a> <span class="special">{</span>
  <span class="comment">// <a class="link" href="pointer_traits.html#boost.intrusive.pointer_traitstypes">types</a></span>
  <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>        
  <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>   
  <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>
  <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>         
  <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>      

  <span class="comment">// <a class="link" href="pointer_traits.html#idp49005200-bb">public static functions</a></span>
  <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pointer_traits.html#idp49005760-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>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pointer_traits.html#idp49011008-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">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pointer_traits.html#idp49017056-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">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pointer_traits.html#idp49023104-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">&amp;</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idp286538784"></a><h2>Description</h2>
<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>
<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>
<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>
<div class="refsect2">
<a name="idp286546016"></a><h3>
<a name="boost.intrusive.pointer_traitstypes"></a><code class="computeroutput">pointer_traits</code> 
        public
       types</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<p>
<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>
<p>The pointer type queried by this <a class="link" href="pointer_traits.html" title="Struct template pointer_traits">pointer_traits</a> instantiation </p>
</li>
<li class="listitem">
<p>
<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>
<p>Ptr::element_type if such a type exists; otherwise, T if Ptr is a class template instantiation of the form SomePointer&lt;T, Args&gt;, where Args is zero or more type arguments ; otherwise , the specialization is ill-formed. </p>
</li>
<li class="listitem">
<p>
<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>
<p>Ptr::difference_type if such a type exists; otherwise, std::ptrdiff_t. </p>
</li>
<li class="listitem">
<p>
<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>
<p>Ptr::rebind&lt;U&gt; if such a type exists; otherwise, SomePointer&lt;U, Args&gt; if Ptr is a class template instantiation of the form SomePointer&lt;T, Args&gt;, where Args is zero or more type arguments ; otherwise, the instantiation of rebind is ill-formed.</p>
<p>For portable code for C++03 and C++11, <span style="color: red">&lt;preformatted&gt;typename rebind_pointer&lt;U&gt;::type&lt;/preformatted&gt;</span> shall be used instead of rebind&lt;U&gt; to obtain a pointer to U. </p>
</li>
<li class="listitem">
<p>
<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>
<p>Ptr::reference if such a type exists (non-standard extension); otherwise, element_type &amp; </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp286569584"></a><h3>
<a name="idp49005200-bb"></a><code class="computeroutput">pointer_traits</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">pointer</span> <a name="idp49005760-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>
<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 &amp;.</p>
<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>
<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>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="idp49011008-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">&amp;</span> uptr<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p>
<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 &amp;). If such function does not exist, returns pointer_to(static_cast&lt;element_type&amp;&gt;(*uptr))</p>
<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>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="idp49017056-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">&amp;</span> uptr<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p>
<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling the static template function Ptr::const_cast_from&lt;UPtr&gt;(UPpr/const UPpr &amp;). If such function does not exist, returns pointer_to(const_cast&lt;element_type&amp;&gt;(*uptr))</p>
<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>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> UPtr<span class="special">&gt;</span> <span class="keyword">static</span> <span class="identifier">pointer</span> <a name="idp49023104-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">&amp;</span> uptr<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Remark</strong></span>: Non-standard extension.</p>
<p><span class="bold"><strong>Returns</strong></span>: A dereferenceable pointer to r obtained by calling the static template function Ptr::dynamic_cast_from&lt;UPtr&gt;(UPpr/const UPpr &amp;). If such function does not exist, returns pointer_to(<span class="emphasis"><em>dynamic_cast&lt;element_type</em></span>&gt;(&amp;*uptr))</p>
<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>
</li>
</ol></div>
</div>
</div>
</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 &#169; 2005 Olaf Krzikalla<br>Copyright &#169; 2006-2015 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="pointer_rebind_idp48981792.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_traits_idp49029744.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>