summaryrefslogtreecommitdiff
path: root/doc/html/boost/container/pmr/polymorphic_allocator.html
blob: 0576e00cc80357679244a9f4699ba2d8ae88fa8f (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
135
136
137
138
139
140
141
142
<!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>Class template polymorphic_allocator</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../../boost_container_header_reference.html#header.boost.container.pmr.polymorphic_allocator_hpp" title="Header &lt;boost/container/pmr/polymorphic_allocator.hpp&gt;">
<link rel="prev" href="monotonic_buffer_resource.html" title="Class monotonic_buffer_resource">
<link rel="next" href="operator__.html" title="Function template operator==">
</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="monotonic_buffer_resource.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../boost_container_header_reference.html#header.boost.container.pmr.polymorphic_allocator_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="operator__.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.container.pmr.polymorphic_allocator"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template polymorphic_allocator</span></h2>
<p>boost::container::pmr::polymorphic_allocator</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="../../../boost_container_header_reference.html#header.boost.container.pmr.polymorphic_allocator_hpp" title="Header &lt;boost/container/pmr/polymorphic_allocator.hpp&gt;">boost/container/pmr/polymorphic_allocator.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">T</span> <a name="boost.container.pmr.polymorphic_allocator.value_type"></a><span class="identifier">value_type</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="polymorphic_allocator.html#boost.container.pmr.polymorphic_allocatorconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="polymorphic_allocator.html#idp56298640-bb"><span class="identifier">polymorphic_allocator</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <a class="link" href="polymorphic_allocator.html#idp56300624-bb"><span class="identifier">polymorphic_allocator</span></a><span class="special">(</span><a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">*</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="polymorphic_allocator.html#idp56305552-bb"><span class="identifier">polymorphic_allocator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <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> U<span class="special">&gt;</span> 
    <a class="link" href="polymorphic_allocator.html#idp56307968-bb"><span class="identifier">polymorphic_allocator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a><span class="special">&lt;</span> <span class="identifier">U</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <span class="special">&amp;</span> <a class="link" href="polymorphic_allocator.html#idp56311504-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="polymorphic_allocator.html#idp56272320-bb">public member functions</a></span>
  <span class="identifier">T</span> <span class="special">*</span> <a class="link" href="polymorphic_allocator.html#idp56272880-bb"><span class="identifier">allocate</span></a><span class="special">(</span><span class="identifier">size_t</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="polymorphic_allocator.html#idp56275888-bb"><span class="identifier">deallocate</span></a><span class="special">(</span><span class="identifier">T</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Args<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="polymorphic_allocator.html#idp56281360-bb"><span class="identifier">construct</span></a><span class="special">(</span><span class="identifier">U</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">Args</span> <span class="special">&amp;&amp;</span><span class="special">...</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="polymorphic_allocator.html#idp56290048-bb"><span class="identifier">destroy</span></a><span class="special">(</span><span class="identifier">U</span> <span class="special">*</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <a class="link" href="polymorphic_allocator.html#idp56293408-bb"><span class="identifier">select_on_container_copy_construction</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">*</span> <a class="link" href="polymorphic_allocator.html#idp56296096-bb"><span class="identifier">resource</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.10.15.23.3.4"></a><h2>Description</h2>
<p>A specialization of class template <code class="computeroutput"><a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a></code> conforms to the Allocator requirements. Constructed with different memory resources, different instances of the same specialization of <code class="computeroutput"><a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a></code> can exhibit entirely different allocation behavior. This runtime polymorphism allows objects that use <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> to behave as if they used different allocator types at run time even though they use the same static allocator type. </p>
<div class="refsect2">
<a name="id-1.3.10.15.23.3.4.3"></a><h3>
<a name="boost.container.pmr.polymorphic_allocatorconstruct-copy-destruct"></a><code class="computeroutput">polymorphic_allocator</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="idp56298640-bb"></a><span class="identifier">polymorphic_allocator</span><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: Sets m_resource to <code class="computeroutput">get_default_resource()</code>. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp56300624-bb"></a><span class="identifier">polymorphic_allocator</span><span class="special">(</span><a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">*</span> r<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Requires</strong></span>: r is non-null.</p>
<p><span class="bold"><strong>Effects</strong></span>: Sets m_resource to r.</p>
<p><span class="bold"><strong>Throws</strong></span>: Nothing</p>
<p><span class="bold"><strong>Notes</strong></span>: This constructor provides an implicit conversion from memory_resource*. Non-standard extension: if r is null m_resource is set to get_default_resource(). </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp56305552-bb"></a><span class="identifier">polymorphic_allocator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: Sets m_resource to other.resource(). </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">&gt;</span> 
  <a name="idp56307968-bb"></a><span class="identifier">polymorphic_allocator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a><span class="special">&lt;</span> <span class="identifier">U</span> <span class="special">&gt;</span> <span class="special">&amp;</span> other<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: Sets m_resource to other.resource(). </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <span class="special">&amp;</span> <a name="idp56311504-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: Sets m_resource to other.resource(). </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.10.15.23.3.4.4"></a><h3>
<a name="idp56272320-bb"></a><code class="computeroutput">polymorphic_allocator</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">T</span> <span class="special">*</span> <a name="idp56272880-bb"></a><span class="identifier">allocate</span><span class="special">(</span><span class="identifier">size_t</span> n<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Returns</strong></span>: Equivalent to <code class="computeroutput">static_cast&lt;T*&gt;(m_resource-&gt;allocate(n * sizeof(T), alignof(T)))</code>. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp56275888-bb"></a><span class="identifier">deallocate</span><span class="special">(</span><span class="identifier">T</span> <span class="special">*</span> p<span class="special">,</span> <span class="identifier">size_t</span> n<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Requires</strong></span>: p was allocated from a memory resource, x, equal to *m_resource, using <code class="computeroutput">x.allocate(n * sizeof(T), alignof(T))</code>.</p>
<p><span class="bold"><strong>Effects</strong></span>: Equivalent to m_resource-&gt;deallocate(p, n * sizeof(T), alignof(T)).</p>
<p><span class="bold"><strong>Throws</strong></span>: Nothing. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Args<span class="special">&gt;</span> <span class="keyword">void</span> <a name="idp56281360-bb"></a><span class="identifier">construct</span><span class="special">(</span><span class="identifier">U</span> <span class="special">*</span> p<span class="special">,</span> <span class="identifier">Args</span> <span class="special">&amp;&amp;</span><span class="special">...</span> args<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Requires</strong></span>: Uses-allocator construction of T with allocator <code class="computeroutput">*this</code> and constructor arguments <code class="computeroutput">std::forward&lt;Args&gt;(args)...</code> is well-formed. [Note: uses-allocator construction is always well formed for types that do not use allocators. - end note]</p>
<p><span class="bold"><strong>Effects</strong></span>: Construct a T object at p by uses-allocator construction with allocator <code class="computeroutput">*this</code> and constructor arguments <code class="computeroutput">std::forward&lt;Args&gt;(args)...</code>.</p>
<p><span class="bold"><strong>Throws</strong></span>: Nothing unless the constructor for T throws. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">&gt;</span> <span class="keyword">void</span> <a name="idp56290048-bb"></a><span class="identifier">destroy</span><span class="special">(</span><span class="identifier">U</span> <span class="special">*</span> p<span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: p-&gt;~U(). </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="polymorphic_allocator.html" title="Class template polymorphic_allocator">polymorphic_allocator</a> <a name="idp56293408-bb"></a><span class="identifier">select_on_container_copy_construction</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Returns</strong></span>: Equivalent to <code class="computeroutput">polymorphic_allocator()</code>. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">*</span> <a name="idp56296096-bb"></a><span class="identifier">resource</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Returns</strong></span>: m_resource. </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; 2009-2017 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="monotonic_buffer_resource.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../boost_container_header_reference.html#header.boost.container.pmr.polymorphic_allocator_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="operator__.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>