]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/pool/doc/html/boost/pool_allocator.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / pool / doc / html / boost / pool_allocator.html
CommitLineData
7c673cae
FG
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4<title>Class template pool_allocator</title>
5<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7<link rel="home" href="../index.html" title="Boost.Pool">
8<link rel="up" href="../header/boost/pool/pool_alloc_hpp.html" title="Header &lt;boost/pool/pool_alloc.hpp&gt;">
9<link rel="prev" href="pool_allocator_tag.html" title="Struct pool_allocator_tag">
10<link rel="next" href="pool_allocator/rebind.html" title="Struct template rebind">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="pool_allocator_tag.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../header/boost/pool/pool_alloc_hpp.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="pool_allocator/rebind.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="refentry">
26<a name="boost.pool_allocator"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class template pool_allocator</span></h2>
29<p>boost::pool_allocator &#8212; A C++ Standard Library conforming allocator, based on an underlying pool. </p>
30</div>
31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32<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="../header/boost/pool/pool_alloc_hpp.html" title="Header &lt;boost/pool/pool_alloc.hpp&gt;">boost/pool/pool_alloc.hpp</a>&gt;
33
34</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">typename</span> UserAllocator<span class="special">,</span> <span class="keyword">typename</span> Mutex<span class="special">,</span>
35 <span class="keyword">unsigned</span> NextSize<span class="special">,</span> <span class="keyword">unsigned</span> MaxSize<span class="special">&gt;</span>
36<span class="keyword">class</span> <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a> <span class="special">{</span>
37<span class="keyword">public</span><span class="special">:</span>
38 <span class="comment">// types</span>
39 <span class="keyword">typedef</span> <span class="identifier">T</span> <a name="boost.pool_allocator.value_type"></a><span class="identifier">value_type</span><span class="special">;</span> <span class="comment">// value_type of template parameter T. </span>
40 <span class="keyword">typedef</span> <span class="identifier">UserAllocator</span> <a name="boost.pool_allocator.user_allocator"></a><span class="identifier">user_allocator</span><span class="special">;</span> <span class="comment">// allocator that defines the method that the underlying Pool will use to allocate memory from the system. </span>
41 <span class="keyword">typedef</span> <span class="identifier">Mutex</span> <a name="boost.pool_allocator.mutex"></a><span class="identifier">mutex</span><span class="special">;</span> <span class="comment">// typedef mutex publishes the value of the template parameter Mutex. </span>
42 <span class="keyword">typedef</span> <span class="identifier">value_type</span> <span class="special">*</span> <a name="boost.pool_allocator.pointer"></a><span class="identifier">pointer</span><span class="special">;</span>
43 <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">*</span> <a name="boost.pool_allocator.const_pointer"></a><span class="identifier">const_pointer</span><span class="special">;</span>
44 <span class="keyword">typedef</span> <span class="identifier">value_type</span> <span class="special">&amp;</span> <a name="boost.pool_allocator.reference"></a><span class="identifier">reference</span><span class="special">;</span>
45 <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&amp;</span> <a name="boost.pool_allocator.const_reference"></a><span class="identifier">const_reference</span><span class="special">;</span>
46 <span class="keyword">typedef</span> <a class="link" href="pool.html" title="Class template pool">pool</a><span class="special">&lt;</span> <span class="identifier">UserAllocator</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">size_type</span> <a name="boost.pool_allocator.size_type"></a><span class="identifier">size_type</span><span class="special">;</span>
47 <span class="keyword">typedef</span> <a class="link" href="pool.html" title="Class template pool">pool</a><span class="special">&lt;</span> <span class="identifier">UserAllocator</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">difference_type</span> <a name="boost.pool_allocator.difference_type"></a><span class="identifier">difference_type</span><span class="special">;</span>
48
49 <span class="comment">// member classes/structs/unions</span>
50
51 <span class="comment">// Nested class rebind allows for transformation from pool_allocator&lt;T&gt; to
52 // pool_allocator&lt;U&gt;.</span>
53 <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">&gt;</span>
54 <span class="keyword">struct</span> <a class="link" href="pool_allocator/rebind.html" title="Struct template rebind">rebind</a> <span class="special">{</span>
55 <span class="comment">// types</span>
56 <span class="keyword">typedef</span> <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a><span class="special">&lt;</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">UserAllocator</span><span class="special">,</span> <span class="identifier">Mutex</span><span class="special">,</span> <span class="identifier">NextSize</span><span class="special">,</span> <span class="identifier">MaxSize</span> <span class="special">&gt;</span> <a class="link" href="pool_allocator/rebind.html#boost.pool_allocator.rebind.other"><span class="identifier">other</span></a><span class="special">;</span>
57 <span class="special">}</span><span class="special">;</span>
58
59 <span class="comment">// <a class="link" href="pool_allocator.html#boost.pool_allocatorconstruct-copy-destruct">construct/copy/destruct</a></span>
60 <a class="link" href="pool_allocator.html#id377842-bb"><span class="identifier">pool_allocator</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
61 <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">&gt;</span>
62 <a class="link" href="pool_allocator.html#id377861-bb"><span class="identifier">pool_allocator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a><span class="special">&lt;</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">UserAllocator</span><span class="special">,</span> <span class="identifier">Mutex</span><span class="special">,</span> <span class="identifier">NextSize</span><span class="special">,</span> <span class="identifier">MaxSize</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
63
64 <span class="comment">// <a class="link" href="pool_allocator.html#id377811-bb">public member functions</a></span>
65 <span class="keyword">bool</span> <a class="link" href="pool_allocator.html#id377813-bb"><span class="keyword">operator</span><span class="special">==</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
66 <span class="keyword">bool</span> <a class="link" href="pool_allocator.html#id377828-bb"><span class="keyword">operator</span><span class="special">!=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
67
68 <span class="comment">// <a class="link" href="pool_allocator.html#id377895-bb">public static functions</a></span>
69 <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pool_allocator.html#id377897-bb"><span class="identifier">address</span></a><span class="special">(</span><span class="identifier">reference</span><span class="special">)</span><span class="special">;</span>
70 <span class="keyword">static</span> <span class="identifier">const_pointer</span> <a class="link" href="pool_allocator.html#id377908-bb"><span class="identifier">address</span></a><span class="special">(</span><span class="identifier">const_reference</span><span class="special">)</span><span class="special">;</span>
71 <span class="keyword">static</span> <span class="identifier">size_type</span> <a class="link" href="pool_allocator.html#id377919-bb"><span class="identifier">max_size</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
72 <span class="keyword">static</span> <span class="keyword">void</span> <a class="link" href="pool_allocator.html#id377925-bb"><span class="identifier">construct</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pointer</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
73 <span class="keyword">static</span> <span class="keyword">void</span> <a class="link" href="pool_allocator.html#id377940-bb"><span class="identifier">destroy</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pointer</span><span class="special">)</span><span class="special">;</span>
74 <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pool_allocator.html#id377951-bb"><span class="identifier">allocate</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
75 <span class="keyword">static</span> <span class="identifier">pointer</span> <a class="link" href="pool_allocator.html#id377962-bb"><span class="identifier">allocate</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">size_type</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">void</span> <span class="special">*</span><span class="special">)</span><span class="special">;</span>
76 <span class="keyword">static</span> <span class="keyword">void</span> <a class="link" href="pool_allocator.html#id377987-bb"><span class="identifier">deallocate</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pointer</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
77
78 <span class="comment">// public data members</span>
79 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">unsigned</span> <span class="identifier">next_size</span><span class="special">;</span> <span class="comment">// next_size publishes the values of the template parameter NextSize. </span>
80<span class="special">}</span><span class="special">;</span></pre></div>
81<div class="refsect1">
82<a name="id933084"></a><h2>Description</h2>
83<p>Template parameters for <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a> are defined as follows:</p>
84<p><span class="bold"><strong>T</strong></span> Type of object to allocate/deallocate.</p>
85<p><span class="bold"><strong>UserAllocator</strong></span>. Defines the method that the underlying Pool will use to allocate memory from the system. See <a href="../boost_pool/pool/pooling.html#boost_pool.pool.pooling.user_allocator" target="_top">User Allocators</a> for details.</p>
86<p><span class="bold"><strong>Mutex</strong></span> Allows the user to determine the type of synchronization to be used on the underlying <a class="link" href="singleton_pool.html" title="Class template singleton_pool">singleton_pool</a>.</p>
87<p><span class="bold"><strong>NextSize</strong></span> The value of this parameter is passed to the underlying <a class="link" href="singleton_pool.html" title="Class template singleton_pool">singleton_pool</a> when it is created.</p>
88<p><span class="bold"><strong>MaxSize</strong></span> Limit on the maximum size used.</p>
89<div class="note"><table border="0" summary="Note">
90<tr>
91<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
92<th align="left">Note</th>
93</tr>
94<tr><td align="left" valign="top"><p>The underlying <a class="link" href="singleton_pool.html" title="Class template singleton_pool">singleton_pool</a> used by the this allocator constructs a pool instance that <span class="bold"><strong>is never freed</strong></span>. This means that memory allocated by the allocator can be still used after main() has completed, but may mean that some memory checking programs will complain about leaks. </p></td></tr>
95</table></div>
96<p>
97</p>
98<div class="refsect2">
99<a name="id933157"></a><h3>
100<a name="boost.pool_allocatorconstruct-copy-destruct"></a><code class="computeroutput">pool_allocator</code>
101 public
102 construct/copy/destruct</h3>
103<div class="orderedlist"><ol class="orderedlist" type="1">
104<li class="listitem">
105<pre class="literallayout"><a name="id377842-bb"></a><span class="identifier">pool_allocator</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
106<p>Results in default construction of the underlying <code class="computeroutput"><a class="link" href="singleton_pool.html" title="Class template singleton_pool">singleton_pool</a></code> IFF an instance of this allocator is constructed during global initialization ( required to ensure construction of <code class="computeroutput"><a class="link" href="singleton_pool.html" title="Class template singleton_pool">singleton_pool</a></code> IFF an instance of this allocator is constructed during global initialization. See ticket #2359 for a complete explanation at <a href="http://svn.boost.org/trac/boost/ticket/2359" target="_top">http://svn.boost.org/trac/boost/ticket/2359</a>) .</p>
107</li>
108<li class="listitem">
109<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">&gt;</span>
110 <a name="id377861-bb"></a><span class="identifier">pool_allocator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a><span class="special">&lt;</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">UserAllocator</span><span class="special">,</span> <span class="identifier">Mutex</span><span class="special">,</span> <span class="identifier">NextSize</span><span class="special">,</span> <span class="identifier">MaxSize</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span></pre>
111<p>Results in the default construction of the underlying <code class="computeroutput"><a class="link" href="singleton_pool.html" title="Class template singleton_pool">singleton_pool</a></code>, this is required to ensure construction of <code class="computeroutput"><a class="link" href="singleton_pool.html" title="Class template singleton_pool">singleton_pool</a></code> IFF an instance of this allocator is constructed during global initialization. See ticket #2359 for a complete explanation at <a href="http://svn.boost.org/trac/boost/ticket/2359" target="_top">http://svn.boost.org/trac/boost/ticket/2359</a> .</p>
112</li>
113</ol></div>
114</div>
115<div class="refsect2">
116<a name="id934733"></a><h3>
117<a name="id377811-bb"></a><code class="computeroutput">pool_allocator</code> public member functions</h3>
118<div class="orderedlist"><ol class="orderedlist" type="1">
119<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="id377813-bb"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
120<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="id377828-bb"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="pool_allocator.html" title="Class template pool_allocator">pool_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
121</ol></div>
122</div>
123<div class="refsect2">
124<a name="id934845"></a><h3>
125<a name="id377895-bb"></a><code class="computeroutput">pool_allocator</code> public static functions</h3>
126<div class="orderedlist"><ol class="orderedlist" type="1">
127<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">pointer</span> <a name="id377897-bb"></a><span class="identifier">address</span><span class="special">(</span><span class="identifier">reference</span> r<span class="special">)</span><span class="special">;</span></pre></li>
128<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">const_pointer</span> <a name="id377908-bb"></a><span class="identifier">address</span><span class="special">(</span><span class="identifier">const_reference</span> s<span class="special">)</span><span class="special">;</span></pre></li>
129<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">size_type</span> <a name="id377919-bb"></a><span class="identifier">max_size</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
130<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="keyword">void</span> <a name="id377925-bb"></a><span class="identifier">construct</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pointer</span> ptr<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&amp;</span> t<span class="special">)</span><span class="special">;</span></pre></li>
131<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="keyword">void</span> <a name="id377940-bb"></a><span class="identifier">destroy</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pointer</span> ptr<span class="special">)</span><span class="special">;</span></pre></li>
132<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">pointer</span> <a name="id377951-bb"></a><span class="identifier">allocate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">size_type</span> n<span class="special">)</span><span class="special">;</span></pre></li>
133<li class="listitem">
134<pre class="literallayout"><span class="keyword">static</span> <span class="identifier">pointer</span> <a name="id377962-bb"></a><span class="identifier">allocate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">size_type</span> n<span class="special">,</span> <span class="keyword">const</span> <span class="keyword">void</span> <span class="special">*</span> const<span class="special">)</span><span class="special">;</span></pre>
135<p>allocate n bytes</p>
136<p>
137</p>
138<div class="variablelist"><table border="0">
139<col align="left" valign="top">
140<tbody><tr>
141<td><p><span class="term">Parameters:</span></p></td>
142<td><div class="variablelist"><table border="0">
143<col align="left" valign="top">
144<tbody><tr>
145<td><p><span class="term"><code class="computeroutput">n</code></span></p></td>
146<td><p>bytes to allocate. </p></td>
147</tr></tbody>
148</table></div></td>
149</tr></tbody>
150</table></div>
151</li>
152<li class="listitem">
153<pre class="literallayout"><span class="keyword">static</span> <span class="keyword">void</span> <a name="id377987-bb"></a><span class="identifier">deallocate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pointer</span> ptr<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">size_type</span> n<span class="special">)</span><span class="special">;</span></pre>
154<p>Deallocate n bytes from ptr
155</p>
156<div class="variablelist"><table border="0">
157<col align="left" valign="top">
158<tbody><tr>
159<td><p><span class="term">Parameters:</span></p></td>
160<td><div class="variablelist"><table border="0">
161<col align="left" valign="top">
162<tbody>
163<tr>
164<td><p><span class="term"><code class="computeroutput">n</code></span></p></td>
165<td><p>number of bytes to deallocate. </p></td>
166</tr>
167<tr>
168<td><p><span class="term"><code class="computeroutput">ptr</code></span></p></td>
169<td><p>location to deallocate from. </p></td>
170</tr>
171</tbody>
172</table></div></td>
173</tr></tbody>
174</table></div>
175</li>
176</ol></div>
177</div>
178<div class="refsect2">
179<a name="id935438"></a><h3>Specializations</h3>
180<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p><a class="link" href="pool_allocator_void__UserAllocator__M_id378014.html" title="Class template pool_allocator&lt;void, UserAllocator, Mutex, NextSize, MaxSize&gt;">Class template pool_allocator&lt;void, UserAllocator, Mutex, NextSize, MaxSize&gt;</a></p></li></ul></div>
181</div>
182</div>
183</div>
184<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
185<td align="left"></td>
186<td align="right"><div class="copyright-footer">Copyright &#169; 2000-2006 Stephen Cleary<br>Copyright &#169; 2011 Paul A. Bristow<p>
187 Distributed under the Boost Software License, Version 1.0. (See accompanying
188 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>)
189 </p>
190</div></td>
191</tr></table>
192<hr>
193<div class="spirit-nav">
194<a accesskey="p" href="pool_allocator_tag.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../header/boost/pool/pool_alloc_hpp.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="pool_allocator/rebind.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
195</div>
196</body>
197</html>