summaryrefslogtreecommitdiff
path: root/doc/html/boost/container/pmr/memory_resource.html
blob: 9029b05c31aaf33de9c732dc64c74965a315758b (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
143
<!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 memory_resource</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.memory_resource_hpp" title="Header &lt;boost/container/pmr/memory_resource.hpp&gt;">
<link rel="prev" href="get_default_resource.html" title="Function get_default_resource">
<link rel="next" href="monotonic_buffer_resource.html" title="Class monotonic_buffer_resource">
</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="get_default_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.memory_resource_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="monotonic_buffer_resource.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.container.pmr.memory_resource"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class memory_resource</span></h2>
<p>boost::container::pmr::memory_resource</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.memory_resource_hpp" title="Header &lt;boost/container/pmr/memory_resource.hpp&gt;">boost/container/pmr/memory_resource.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// <a class="link" href="memory_resource.html#boost.container.pmr.memory_resourceconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="memory_resource.html#idp56148288-bb"><span class="special">~</span><span class="identifier">memory_resource</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="memory_resource.html#idp56135280-bb">public member functions</a></span>
  <span class="keyword">void</span> <span class="special">*</span> <a class="link" href="memory_resource.html#idp56135840-bb"><span class="identifier">allocate</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">=</span> <span class="identifier">max_align</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="memory_resource.html#idp56139792-bb"><span class="identifier">deallocate</span></a><span class="special">(</span><span class="keyword">void</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="special">=</span> <span class="identifier">max_align</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="memory_resource.html#idp56144432-bb"><span class="identifier">is_equal</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="memory_resource.html#idp56150288-bb">friend functions</a></span>
  <span class="keyword">friend</span> <span class="keyword">bool</span> <a class="link" href="memory_resource.html#idp56150848-bb"><span class="keyword">operator</span><span class="special">==</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">friend</span> <span class="keyword">bool</span> <a class="link" href="memory_resource.html#idp56155680-bb"><span class="keyword">operator</span><span class="special">!=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="memory_resource.html#idp56160208-bb">protected member functions</a></span>
  <span class="keyword">virtual</span> <span class="keyword">void</span> <span class="special">*</span> <a class="link" href="memory_resource.html#idp56160784-bb"><span class="identifier">do_allocate</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
  <span class="keyword">virtual</span> <span class="keyword">void</span> <a class="link" href="memory_resource.html#idp56166608-bb"><span class="identifier">do_deallocate</span></a><span class="special">(</span><span class="keyword">void</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
  <span class="keyword">virtual</span> <span class="keyword">bool</span> <a class="link" href="memory_resource.html#idp56173376-bb"><span class="identifier">do_is_equal</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>

  <span class="comment">// public data members</span>
  <span class="keyword">static</span> <span class="keyword">constexpr</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_align</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.21.3.4"></a><h2>Description</h2>
<p>The <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> class is an abstract interface to an unbounded set of classes encapsulating memory resources. </p>
<div class="refsect2">
<a name="id-1.3.10.15.21.3.4.3"></a><h3>
<a name="boost.container.pmr.memory_resourceconstruct-copy-destruct"></a><code class="computeroutput">memory_resource</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><a name="idp56148288-bb"></a><span class="special">~</span><span class="identifier">memory_resource</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: Destroys this <code class="computeroutput"><a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a></code>. </p>
</li></ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.10.15.21.3.4.4"></a><h3>
<a name="idp56135280-bb"></a><code class="computeroutput">memory_resource</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <span class="special">*</span> <a name="idp56135840-bb"></a><span class="identifier">allocate</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> bytes<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> alignment <span class="special">=</span> <span class="identifier">max_align</span><span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: Equivalent to <code class="computeroutput">return do_allocate(bytes, alignment);</code> </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp56139792-bb"></a><span class="identifier">deallocate</span><span class="special">(</span><span class="keyword">void</span> <span class="special">*</span> p<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> bytes<span class="special">,</span> 
                <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> alignment <span class="special">=</span> <span class="identifier">max_align</span><span class="special">)</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: Equivalent to <code class="computeroutput">return do_deallocate(bytes, alignment);</code> </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idp56144432-bb"></a><span class="identifier">is_equal</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span> other<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Effects</strong></span>: Equivalent to <code class="computeroutput">return return do_is_equal(other);</code> </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.10.15.21.3.4.5"></a><h3>
<a name="idp56150288-bb"></a><code class="computeroutput">memory_resource</code> friend functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">friend</span> <span class="keyword">bool</span> <a name="idp56150848-bb"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span> a<span class="special">,</span> <span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span> b<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Returns</strong></span>: <code class="computeroutput">&amp;a == &amp;b || a.is_equal(b)</code>. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">friend</span> <span class="keyword">bool</span> <a name="idp56155680-bb"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span> a<span class="special">,</span> <span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span> b<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Returns</strong></span>: !(a == b). </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.10.15.21.3.4.6"></a><h3>
<a name="idp56160208-bb"></a><code class="computeroutput">memory_resource</code> protected member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> <span class="special">*</span> <a name="idp56160784-bb"></a><span class="identifier">do_allocate</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> bytes<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> alignment<span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Requires</strong></span>: Alignment shall be a power of two.</p>
<p><span class="bold"><strong>Returns</strong></span>: A derived class shall implement this function to return a pointer to allocated storage with a size of at least bytes. The returned storage is aligned to the specified alignment, if such alignment is supported; otherwise it is aligned to max_align.</p>
<p><span class="bold"><strong>Throws</strong></span>: A derived class implementation shall throw an appropriate exception if it is unable to allocate memory with the requested size and alignment. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">void</span> 
<a name="idp56166608-bb"></a><span class="identifier">do_deallocate</span><span class="special">(</span><span class="keyword">void</span> <span class="special">*</span> p<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> bytes<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> alignment<span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Requires</strong></span>: p shall have been returned from a prior call to <code class="computeroutput">allocate(bytes, alignment)</code> on a memory resource equal to *this, and the storage at p shall not yet have been deallocated.</p>
<p><span class="bold"><strong>Effects</strong></span>: A derived class shall implement this function to dispose of allocated storage.</p>
<p><span class="bold"><strong>Throws</strong></span>: Nothing. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">virtual</span> <span class="keyword">bool</span> <a name="idp56173376-bb"></a><span class="identifier">do_is_equal</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="memory_resource.html" title="Class memory_resource">memory_resource</a> <span class="special">&amp;</span> other<span class="special">)</span> <span class="keyword">const</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span></pre>
<p><span class="bold"><strong>Returns</strong></span>: A derived class shall implement this function to return true if memory allocated from this can be deallocated from other and vice-versa; otherwise it shall return false. <span class="emphasis"><em>[Note: The most-derived type of other might not match the type of this. For a derived class, D, a typical implementation of this function will compute <code class="computeroutput">dynamic_cast&lt;const D*&gt;(&amp;other)</code> and go no further (i.e., return false) if it returns nullptr. - end note]</em></span>. </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="get_default_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.memory_resource_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="monotonic_buffer_resource.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>