• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>Class template unique_ptr</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="../../move/reference.html#header.boost.move.unique_ptr_hpp" title="Header &lt;boost/move/unique_ptr.hpp&gt;">
10<link rel="prev" href="../has_trivi_1_3_26_20_13_1_2.html" title="Struct template has_trivial_destructor_after_move">
11<link rel="next" href="swap.html" title="Function template swap">
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="../has_trivi_1_3_26_20_13_1_2.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../move/reference.html#header.boost.move.unique_ptr_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="swap.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
25</div>
26<div class="refentry">
27<a name="boost.movelib.unique_ptr"></a><div class="titlepage"></div>
28<div class="refnamediv">
29<h2><span class="refentrytitle">Class template unique_ptr</span></h2>
30<p>boost::movelib::unique_ptr</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: &lt;<a class="link" href="../../move/reference.html#header.boost.move.unique_ptr_hpp" title="Header &lt;boost/move/unique_ptr.hpp&gt;">boost/move/unique_ptr.hpp</a>&gt;
34
35</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> D <span class="special">=</span> <a class="link" href="default_delete.html" title="Struct template default_delete">default_delete</a><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="special">&gt;</span>
36<span class="keyword">class</span> <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">{</span>
37<span class="keyword">public</span><span class="special">:</span>
38  <span class="comment">// <a class="link" href="unique_ptr.html#boost.movelib.unique_ptrtypes">types</a></span>
39  <span class="keyword">typedef</span> <span class="identifier">see_documentation</span> <a class="link" href="unique_ptr.html#boost.movelib.unique_ptr.pointer"><span class="identifier">pointer</span></a><span class="special">;</span>
40  <span class="keyword">typedef</span> <span class="identifier">see_documentation</span> <a class="link" href="unique_ptr.html#boost.movelib.unique_ptr.element_type"><span class="identifier">element_type</span></a><span class="special">;</span>
41  <span class="keyword">typedef</span> <span class="identifier">D</span>                 <a name="boost.movelib.unique_ptr.deleter_type"></a><span class="identifier">deleter_type</span><span class="special">;</span>
42
43  <span class="comment">// <a class="link" href="unique_ptr.html#boost.movelib.unique_ptrconstruct-copy-destruct">construct/copy/destruct</a></span>
44  <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_7-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
45  <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_9-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
46  <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_10-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
47  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span> <span class="keyword">explicit</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_11-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="identifier">Pointer</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
48  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_12-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="identifier">Pointer</span><span class="special">,</span> <span class="identifier">see_documentation</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
49  <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_13-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">,</span> <span class="identifier">see_documentation</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
50  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_14-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="identifier">Pointer</span><span class="special">,</span> <span class="identifier">see_documentation</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
51  <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_15-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">,</span> <span class="identifier">see_documentation</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
52  <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_16-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
53  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">,</span> <span class="keyword">typename</span> E<span class="special">&gt;</span>
54    <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_17-bb"><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="identifier">BOOST_RV_REF_BEG_IF_CXX11</span> <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a><span class="special">&lt;</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">E</span> <span class="special">&gt;</span> <span class="identifier">BOOST_RV_REF_END_IF_CXX11</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
55  <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_8-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
56  <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_19-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
57  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> U<span class="special">,</span> <span class="keyword">typename</span> E<span class="special">&gt;</span>
58    <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_20-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a><span class="special">&lt;</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">E</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
59  <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_21-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
60  <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_18-bb"><span class="special">~</span><span class="identifier">unique_ptr</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
61
62  <span class="comment">// <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6-bb">public member functions</a></span>
63  <span class="identifier">element_type</span> <span class="special">&amp;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_1-bb"><span class="keyword">operator</span> <span class="special">*</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
64  <span class="identifier">element_type</span> <span class="special">&amp;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_2-bb"><span class="keyword">operator</span><span class="special">[</span><span class="special">]</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="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
65  <span class="identifier">pointer</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_3-bb"><span class="keyword">operator</span><span class="special">-&gt;</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
66  <span class="identifier">pointer</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_4-bb"><span class="identifier">get</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
67  <span class="identifier">D</span> <span class="special">&amp;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_5-bb"><span class="identifier">get_deleter</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
68  <span class="keyword">const</span> <span class="identifier">D</span> <span class="special">&amp;</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_6-bb"><span class="identifier">get_deleter</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
69  <span class="keyword">explicit</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_7-bb"><span class="keyword">operator</span> <span class="keyword">bool</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
70  <span class="identifier">pointer</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_8-bb"><span class="identifier">release</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
71  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_9-bb"><span class="identifier">reset</span></a><span class="special">(</span><span class="identifier">Pointer</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
72  <span class="keyword">void</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_10-bb"><span class="identifier">reset</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
73  <span class="keyword">void</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_11-bb"><span class="identifier">reset</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
74  <span class="keyword">void</span> <a class="link" href="unique_ptr.html#id-1_3_26_20_14_3_1_1_6_12-bb"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
75<span class="special">}</span><span class="special">;</span></pre></div>
76<div class="refsect1">
77<a name="id-1.3.26.20.15.5.4"></a><h2>Description</h2>
78<p>A unique pointer is an object that owns another object and manages that other object through a pointer.</p>
79<p>More precisely, a unique pointer is an object u that stores a pointer to a second object p and will dispose of p when u is itself destroyed (e.g., when leaving block scope). In this context, u is said to own p.</p>
80<p>The mechanism by which u disposes of p is known as p's associated deleter, a function object whose correct invocation results in p's appropriate disposition (typically its deletion).</p>
81<p>Let the notation u.p denote the pointer stored by u, and let u.d denote the associated deleter. Upon request, u can reset (replace) u.p and u.d with another pointer and deleter, but must properly dispose of its owned object via the associated deleter before such replacement is considered completed.</p>
82<p>Additionally, u can, upon request, transfer ownership to another unique pointer u2. Upon completion of such a transfer, the following postconditions hold:</p>
83<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
84<li class="listitem"><p>u2.p is equal to the pre-transfer u.p,</p></li>
85<li class="listitem"><p>u.p is equal to nullptr, and</p></li>
86<li class="listitem"><p>if the pre-transfer u.d maintained state, such state has been transferred to u2.d.</p></li>
87</ul></div>
88<p>
89</p>
90<p>As in the case of a reset, u2 must properly dispose of its pre-transfer owned object via the pre-transfer associated deleter before the ownership transfer is considered complete.</p>
91<p>Each object of a type U instantiated from the <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> template specified in this subclause has the strict ownership semantics, specified above, of a unique pointer. In partial satisfaction of these semantics, each such U is MoveConstructible and MoveAssignable, but is not CopyConstructible nor CopyAssignable. The template parameter T of <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> may be an incomplete type.</p>
92<p>The uses of <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> include providing exception safety for dynamically allocated memory, passing ownership of dynamically allocated memory to a function, and returning dynamically allocated memory from a function.</p>
93<p>If T is an array type (e.g. unique_ptr&lt;MyType[]&gt;) the interface is slightly altered:</p>
94<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
95<li class="listitem"><p>Pointers to types derived from T are rejected by the constructors, and by reset.</p></li>
96<li class="listitem"><p>The observers <code class="computeroutput">operator*</code> and <code class="computeroutput">operator-&gt;</code> are not provided.</p></li>
97<li class="listitem"><p>The indexing observer <code class="computeroutput">operator[]</code> is provided.</p></li>
98</ul></div>
99<p>
100</p>
101<p>
102</p>
103<div class="refsect2">
104<a name="id-1.3.26.20.15.5.4.12"></a><h3>Template Parameters</h3>
105<div class="orderedlist"><ol class="orderedlist" type="1">
106<li class="listitem">
107<pre class="literallayout"><span class="keyword">typename</span> T</pre>
108<p>Provides the type of the stored pointer. </p>
109</li>
110<li class="listitem">
111<pre class="literallayout"><span class="keyword">typename</span> D <span class="special">=</span> <a class="link" href="default_delete.html" title="Struct template default_delete">default_delete</a><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></pre>
112<p>The deleter type:</p>
113<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
114<li class="listitem"><p>The default type for the template parameter D is <code class="computeroutput"><a class="link" href="default_delete.html" title="Struct template default_delete">default_delete</a></code>. A client-supplied template argument D shall be a function object type, lvalue-reference to function, or lvalue-reference to function object type for which, given a value d of type D and a value ptr of type unique_ptr&lt;T, D&gt;::pointer, the expression d(ptr) is valid and has the effect of disposing of the pointer as appropriate for that deleter.</p></li>
115<li class="listitem"><p>If the deleter's type D is not a reference type, D shall satisfy the requirements of Destructible.</p></li>
116<li class="listitem"><p>If the type <code class="computeroutput">remove_reference&lt;D&gt;::type::pointer</code> exists, it shall satisfy the requirements of NullablePointer. </p></li>
117</ul></div>
118<p>
119</p>
120</li>
121</ol></div>
122</div>
123<div class="refsect2">
124<a name="id-1.3.26.20.15.5.4.13"></a><h3>
125<a name="boost.movelib.unique_ptrtypes"></a><code class="computeroutput">unique_ptr</code>
126        public
127       types</h3>
128<div class="orderedlist"><ol class="orderedlist" type="1">
129<li class="listitem">
130<p>
131<span class="keyword">typedef</span> <span class="identifier">see_documentation</span> <a name="boost.movelib.unique_ptr.pointer"></a><span class="identifier">pointer</span><span class="special">;</span></p>
132<p>If the type <code class="computeroutput">remove_reference&lt;D&gt;::type::pointer</code> exists, then it shall be a synonym for <code class="computeroutput">remove_reference&lt;D&gt;::type::pointer</code>. Otherwise it shall be a synonym for T*. </p>
133</li>
134<li class="listitem">
135<p>
136<span class="keyword">typedef</span> <span class="identifier">see_documentation</span> <a name="boost.movelib.unique_ptr.element_type"></a><span class="identifier">element_type</span><span class="special">;</span></p>
137<p>If T is an array type, then element_type is equal to T. Otherwise, if T is a type in the form U[], element_type is equal to U. </p>
138</li>
139</ol></div>
140</div>
141<div class="refsect2">
142<a name="id-1.3.26.20.15.5.4.14"></a><h3>
143<a name="boost.movelib.unique_ptrconstruct-copy-destruct"></a><code class="computeroutput">unique_ptr</code>
144        public
145       construct/copy/destruct</h3>
146<div class="orderedlist"><ol class="orderedlist" type="1">
147<li class="listitem"><pre class="literallayout"><a name="id-1_3_26_20_14_3_1_1_7-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span></pre></li>
148<li class="listitem">
149<pre class="literallayout"><a name="id-1_3_26_20_14_3_1_1_9-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
150<p><span class="bold"><strong>Requires</strong></span>: D shall satisfy the requirements of DefaultConstructible, and that construction shall not throw an exception.</p>
151<p><span class="bold"><strong>Effects</strong></span>: Constructs a <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> object that owns nothing, value-initializing the stored pointer and the stored deleter.</p>
152<p><span class="bold"><strong>Postconditions</strong></span>: <code class="computeroutput">get() == nullptr</code>. <code class="computeroutput">get_deleter()</code> returns a reference to the stored deleter.</p>
153<p><span class="bold"><strong>Remarks</strong></span>: If this constructor is instantiated with a pointer type or reference type for the template argument D, the program is ill-formed. </p>
154</li>
155<li class="listitem">
156<pre class="literallayout"><a name="id-1_3_26_20_14_3_1_1_10-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
157<p><span class="bold"><strong>Effects</strong></span>: Same as <code class="computeroutput">unique_ptr()</code> (default constructor). </p>
158</li>
159<li class="listitem">
160<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span> <span class="keyword">explicit</span> <a name="id-1_3_26_20_14_3_1_1_11-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="identifier">Pointer</span> p<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
161<p><span class="bold"><strong>Requires</strong></span>: D shall satisfy the requirements of DefaultConstructible, and that construction shall not throw an exception.</p>
162<p><span class="bold"><strong>Effects</strong></span>: Constructs a <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> which owns p, initializing the stored pointer with p and value initializing the stored deleter.</p>
163<p><span class="bold"><strong>Postconditions</strong></span>: <code class="computeroutput">get() == p</code>. <code class="computeroutput">get_deleter()</code> returns a reference to the stored deleter.</p>
164<p><span class="bold"><strong>Remarks</strong></span>: If this constructor is instantiated with a pointer type or reference type for the template argument D, the program is ill-formed. This constructor shall not participate in overload resolution unless:</p>
165<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
166<li class="listitem"><p>If T is not an array type and Pointer is implicitly convertible to pointer.</p></li>
167<li class="listitem"><p>If T is an array type and Pointer is a more CV qualified pointer to element_type. </p></li>
168</ul></div>
169<p>
170</p>
171</li>
172<li class="listitem">
173<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span>
174  <a name="id-1_3_26_20_14_3_1_1_12-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="identifier">Pointer</span> p<span class="special">,</span> <span class="identifier">see_documentation</span> d1<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
175<p>The signature of this constructor depends upon whether D is a reference type.</p>
176<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
177<li class="listitem"><p>If D is non-reference type A, then the signature is <code class="computeroutput">unique_ptr(pointer p, const A&amp; d)</code>.</p></li>
178<li class="listitem"><p>If D is an lvalue-reference type A&amp;, then the signature is <code class="computeroutput">unique_ptr(pointer p, A&amp; d)</code>.</p></li>
179<li class="listitem"><p>If D is an lvalue-reference type const A&amp;, then the signature is <code class="computeroutput">unique_ptr(pointer p, const A&amp; d)</code>.</p></li>
180</ul></div>
181<p>
182</p>
183<p><span class="bold"><strong>Requires</strong></span>: Either</p>
184<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
185<li class="listitem"><p>D is not an lvalue-reference type and d is an lvalue or const rvalue. D shall satisfy the requirements of CopyConstructible, and the copy constructor of D shall not throw an exception. This <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> will hold a copy of d.</p></li>
186<li class="listitem"><p>D is an lvalue-reference type and d is an lvalue. the type which D references need not be CopyConstructible nor MoveConstructible. This <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> will hold a D which refers to the lvalue d.</p></li>
187</ul></div>
188<p>
189</p>
190<p><span class="bold"><strong>Effects</strong></span>: Constructs a <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> object which owns p, initializing the stored pointer with p and initializing the deleter as described above.</p>
191<p><span class="bold"><strong>Postconditions</strong></span>: <code class="computeroutput">get() == p</code>. <code class="computeroutput">get_deleter()</code> returns a reference to the stored deleter. If D is a reference type then <code class="computeroutput">get_deleter()</code> returns a reference to the lvalue d.</p>
192<p><span class="bold"><strong>Remarks</strong></span>: This constructor shall not participate in overload resolution unless:</p>
193<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
194<li class="listitem"><p>If T is not an array type and Pointer is implicitly convertible to pointer.</p></li>
195<li class="listitem"><p>If T is an array type and Pointer is a more CV qualified pointer to element_type. </p></li>
196</ul></div>
197<p>
198</p>
199</li>
200<li class="listitem">
201<pre class="literallayout"><a name="id-1_3_26_20_14_3_1_1_13-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">,</span> <span class="identifier">see_documentation</span> d1<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
202<p><span class="bold"><strong>Effects</strong></span>: Same effects as <code class="computeroutput">template&lt;class Pointer&gt; unique_ptr(Pointer p, deleter_arg_type1 d1)</code> and additionally <code class="computeroutput">get() == nullptr</code> </p>
203</li>
204<li class="listitem">
205<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span>
206  <a name="id-1_3_26_20_14_3_1_1_14-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="identifier">Pointer</span> p<span class="special">,</span> <span class="identifier">see_documentation</span> d2<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
207<p>The signature of this constructor depends upon whether D is a reference type.</p>
208<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
209<li class="listitem"><p>If D is non-reference type A, then the signature is <code class="computeroutput">unique_ptr(pointer p, A&amp;&amp; d)</code>.</p></li>
210<li class="listitem"><p>If D is an lvalue-reference type A&amp;, then the signature is <code class="computeroutput">unique_ptr(pointer p, A&amp;&amp; d)</code>.</p></li>
211<li class="listitem"><p>If D is an lvalue-reference type const A&amp;, then the signature is <code class="computeroutput">unique_ptr(pointer p, const A&amp;&amp; d)</code>.</p></li>
212</ul></div>
213<p>
214</p>
215<p><span class="bold"><strong>Requires</strong></span>: Either</p>
216<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
217<li class="listitem"><p>D is not an lvalue-reference type and d is a non-const rvalue. D shall satisfy the requirements of MoveConstructible, and the move constructor of D shall not throw an exception. This <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> will hold a value move constructed from d.</p></li>
218<li class="listitem"><p>D is an lvalue-reference type and d is an rvalue, the program is ill-formed.</p></li>
219</ul></div>
220<p>
221</p>
222<p><span class="bold"><strong>Effects</strong></span>: Constructs a <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> object which owns p, initializing the stored pointer with p and initializing the deleter as described above.</p>
223<p><span class="bold"><strong>Postconditions</strong></span>: <code class="computeroutput">get() == p</code>. <code class="computeroutput">get_deleter()</code> returns a reference to the stored deleter. If D is a reference type then <code class="computeroutput">get_deleter()</code> returns a reference to the lvalue d.</p>
224<p><span class="bold"><strong>Remarks</strong></span>: This constructor shall not participate in overload resolution unless:</p>
225<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
226<li class="listitem"><p>If T is not an array type and Pointer is implicitly convertible to pointer.</p></li>
227<li class="listitem"><p>If T is an array type and Pointer is a more CV qualified pointer to element_type. </p></li>
228</ul></div>
229<p>
230</p>
231</li>
232<li class="listitem">
233<pre class="literallayout"><a name="id-1_3_26_20_14_3_1_1_15-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">,</span> <span class="identifier">see_documentation</span> d2<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
234<p><span class="bold"><strong>Effects</strong></span>: Same effects as <code class="computeroutput">template&lt;class Pointer&gt; unique_ptr(Pointer p, deleter_arg_type2 d2)</code> and additionally <code class="computeroutput">get() == nullptr</code> </p>
235</li>
236<li class="listitem">
237<pre class="literallayout"><a name="id-1_3_26_20_14_3_1_1_16-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;&amp;</span> u<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
238<p><span class="bold"><strong>Requires</strong></span>: If D is not a reference type, D shall satisfy the requirements of MoveConstructible. Construction of the deleter from an rvalue of type D shall not throw an exception.</p>
239<p><span class="bold"><strong>Effects</strong></span>: Constructs a <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> by transferring ownership from u to *this. If D is a reference type, this deleter is copy constructed from u's deleter; otherwise, this deleter is move constructed from u's deleter.</p>
240<p><span class="bold"><strong>Postconditions</strong></span>: <code class="computeroutput">get()</code> yields the value u.get() yielded before the construction. <code class="computeroutput">get_deleter()</code> returns a reference to the stored deleter that was constructed from u.get_deleter(). If D is a reference type then <code class="computeroutput">get_deleter()</code> and <code class="computeroutput">u.get_deleter()</code> both reference the same lvalue deleter. </p>
241</li>
242<li class="listitem">
243<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">typename</span> E<span class="special">&gt;</span>
244  <a name="id-1_3_26_20_14_3_1_1_17-bb"></a><span class="identifier">unique_ptr</span><span class="special">(</span><span class="identifier">BOOST_RV_REF_BEG_IF_CXX11</span> <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a><span class="special">&lt;</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">E</span> <span class="special">&gt;</span> <span class="identifier">BOOST_RV_REF_END_IF_CXX11</span> u<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
245<p><span class="bold"><strong>Requires</strong></span>: If E is not a reference type, construction of the deleter from an rvalue of type E shall be well formed and shall not throw an exception. Otherwise, E is a reference type and construction of the deleter from an lvalue of type E shall be well formed and shall not throw an exception.</p>
246<p><span class="bold"><strong>Remarks</strong></span>: This constructor shall not participate in overload resolution unless:</p>
247<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
248<li class="listitem"><p><code class="computeroutput">unique_ptr&lt;U, E&gt;::pointer</code> is implicitly convertible to pointer,</p></li>
249<li class="listitem"><p>U is not an array type, and</p></li>
250<li class="listitem"><p>either D is a reference type and E is the same type as D, or D is not a reference type and E is implicitly convertible to D.</p></li>
251</ul></div>
252<p>
253</p>
254<p><span class="bold"><strong>Effects</strong></span>: Constructs a <code class="computeroutput"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a></code> by transferring ownership from u to *this. If E is a reference type, this deleter is copy constructed from u's deleter; otherwise, this deleter is move constructed from u's deleter.</p>
255<p><span class="bold"><strong>Postconditions</strong></span>: <code class="computeroutput">get()</code> yields the value <code class="computeroutput">u.get()</code> yielded before the construction. <code class="computeroutput">get_deleter()</code> returns a reference to the stored deleter that was constructed from <code class="computeroutput">u.get_deleter()</code>. </p>
256</li>
257<li class="listitem"><pre class="literallayout"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> <a name="id-1_3_26_20_14_3_1_1_8-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span></pre></li>
258<li class="listitem">
259<pre class="literallayout"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> <a name="id-1_3_26_20_14_3_1_1_19-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;&amp;</span> u<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
260<p><span class="bold"><strong>Requires</strong></span>: If D is not a reference type, D shall satisfy the requirements of MoveAssignable and assignment of the deleter from an rvalue of type D shall not throw an exception. Otherwise, D is a reference type; <code class="computeroutput">remove_reference&lt;D&gt;::type</code> shall satisfy the CopyAssignable requirements and assignment of the deleter from an lvalue of type D shall not throw an exception.</p>
261<p><span class="bold"><strong>Effects</strong></span>: Transfers ownership from u to *this as if by calling <code class="computeroutput">reset(u.release())</code> followed by <code class="computeroutput">get_deleter() = std::forward&lt;D&gt;(u.get_deleter())</code>.</p>
262<p><span class="bold"><strong>Returns</strong></span>: *this. </p>
263</li>
264<li class="listitem">
265<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">typename</span> E<span class="special">&gt;</span>
266  <a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> <a name="id-1_3_26_20_14_3_1_1_20-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a><span class="special">&lt;</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">E</span> <span class="special">&gt;</span> <span class="special">&amp;&amp;</span> u<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
267<p><span class="bold"><strong>Requires</strong></span>: If E is not a reference type, assignment of the deleter from an rvalue of type E shall be well-formed and shall not throw an exception. Otherwise, E is a reference type and assignment of the deleter from an lvalue of type E shall be well-formed and shall not throw an exception.</p>
268<p><span class="bold"><strong>Remarks</strong></span>: This operator shall not participate in overload resolution unless:</p>
269<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
270<li class="listitem"><p><code class="computeroutput">unique_ptr&lt;U, E&gt;::pointer</code> is implicitly convertible to pointer and</p></li>
271<li class="listitem"><p>U is not an array type.</p></li>
272</ul></div>
273<p>
274</p>
275<p><span class="bold"><strong>Effects</strong></span>: Transfers ownership from u to *this as if by calling <code class="computeroutput">reset(u.release())</code> followed by <code class="computeroutput">get_deleter() = std::forward&lt;E&gt;(u.get_deleter())</code>.</p>
276<p><span class="bold"><strong>Returns</strong></span>: *this. </p>
277</li>
278<li class="listitem">
279<pre class="literallayout"><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> <a name="id-1_3_26_20_14_3_1_1_21-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
280<p><span class="bold"><strong>Effects</strong></span>: <code class="computeroutput">reset()</code>.</p>
281<p><span class="bold"><strong>Postcondition</strong></span>: <code class="computeroutput">get() == nullptr</code></p>
282<p><span class="bold"><strong>Returns</strong></span>: *this. </p>
283</li>
284<li class="listitem">
285<pre class="literallayout"><a name="id-1_3_26_20_14_3_1_1_18-bb"></a><span class="special">~</span><span class="identifier">unique_ptr</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
286<p><span class="bold"><strong>Requires</strong></span>: The expression <code class="computeroutput">get_deleter()(get())</code> shall be well formed, shall have well-defined behavior, and shall not throw exceptions.</p>
287<p><span class="bold"><strong>Effects</strong></span>: If <code class="computeroutput">get() == nullpt1r</code> there are no effects. Otherwise <code class="computeroutput">get_deleter()(get())</code>.</p>
288<p><span class="bold"><strong>Note</strong></span>: The use of <code class="computeroutput"><a class="link" href="default_delete.html" title="Struct template default_delete">default_delete</a></code> requires T to be a complete type </p>
289</li>
290</ol></div>
291</div>
292<div class="refsect2">
293<a name="id-1.3.26.20.15.5.4.15"></a><h3>
294<a name="id-1_3_26_20_14_3_1_1_6-bb"></a><code class="computeroutput">unique_ptr</code> public member functions</h3>
295<div class="orderedlist"><ol class="orderedlist" type="1">
296<li class="listitem">
297<pre class="literallayout"><span class="identifier">element_type</span> <span class="special">&amp;</span> <a name="id-1_3_26_20_14_3_1_1_6_1-bb"></a><span class="keyword">operator</span> <span class="special">*</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
298<p><span class="bold"><strong>Requires</strong></span>: <code class="computeroutput">get() != nullptr</code>.</p>
299<p><span class="bold"><strong>Returns</strong></span>: <code class="computeroutput">*get()</code>.</p>
300<p><span class="bold"><strong>Remarks&lt;/b: If T is an array type, the program is ill-formed. </strong></span></p>
301</li>
302<li class="listitem">
303<pre class="literallayout"><span class="identifier">element_type</span> <span class="special">&amp;</span> <a name="id-1_3_26_20_14_3_1_1_6_2-bb"></a><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> i<span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
304<p><span class="bold"><strong>Requires</strong></span>: i &lt; the number of elements in the array to which the stored pointer points.</p>
305<p><span class="bold"><strong>Returns</strong></span>: <code class="computeroutput">get()[i]</code>.</p>
306<p><span class="bold"><strong>Remarks&lt;/b: If T is not an array type, the program is ill-formed. </strong></span></p>
307</li>
308<li class="listitem">
309<pre class="literallayout"><span class="identifier">pointer</span> <a name="id-1_3_26_20_14_3_1_1_6_3-bb"></a><span class="keyword">operator</span><span class="special">-&gt;</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
310<p><span class="bold"><strong>Requires</strong></span>: <code class="computeroutput">get() != nullptr</code>.</p>
311<p><span class="bold"><strong>Returns</strong></span>: <code class="computeroutput">get()</code>.</p>
312<p><span class="bold"><strong>Note</strong></span>: use typically requires that T be a complete type.</p>
313<p><span class="bold"><strong>Remarks&lt;/b: If T is an array type, the program is ill-formed. </strong></span></p>
314</li>
315<li class="listitem">
316<pre class="literallayout"><span class="identifier">pointer</span> <a name="id-1_3_26_20_14_3_1_1_6_4-bb"></a><span class="identifier">get</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
317<p><span class="bold"><strong>Returns</strong></span>: The stored pointer. </p>
318</li>
319<li class="listitem">
320<pre class="literallayout"><span class="identifier">D</span> <span class="special">&amp;</span> <a name="id-1_3_26_20_14_3_1_1_6_5-bb"></a><span class="identifier">get_deleter</span><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
321<p><span class="bold"><strong>Returns</strong></span>: A reference to the stored deleter. </p>
322</li>
323<li class="listitem">
324<pre class="literallayout"><span class="keyword">const</span> <span class="identifier">D</span> <span class="special">&amp;</span> <a name="id-1_3_26_20_14_3_1_1_6_6-bb"></a><span class="identifier">get_deleter</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
325<p><span class="bold"><strong>Returns</strong></span>: A reference to the stored deleter. </p>
326</li>
327<li class="listitem">
328<pre class="literallayout"><span class="keyword">explicit</span> <a name="id-1_3_26_20_14_3_1_1_6_7-bb"></a><span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
329<p><span class="bold"><strong>Returns</strong></span>: Returns: get() != nullptr. </p>
330</li>
331<li class="listitem">
332<pre class="literallayout"><span class="identifier">pointer</span> <a name="id-1_3_26_20_14_3_1_1_6_8-bb"></a><span class="identifier">release</span><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
333<p><span class="bold"><strong>Postcondition</strong></span>: <code class="computeroutput">get() == nullptr</code>.</p>
334<p><span class="bold"><strong>Returns</strong></span>: The value <code class="computeroutput">get()</code> had at the start of the call to release. </p>
335</li>
336<li class="listitem">
337<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span> <span class="keyword">void</span> <a name="id-1_3_26_20_14_3_1_1_6_9-bb"></a><span class="identifier">reset</span><span class="special">(</span><span class="identifier">Pointer</span> p<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
338<p><span class="bold"><strong>Requires</strong></span>: The expression <code class="computeroutput">get_deleter()(get())</code> shall be well formed, shall have well-defined behavior, and shall not throw exceptions.</p>
339<p><span class="bold"><strong>Effects</strong></span>: assigns p to the stored pointer, and then if the old value of the stored pointer, old_p, was not equal to nullptr, calls <code class="computeroutput">get_deleter()(old_p)</code>. Note: The order of these operations is significant because the call to <code class="computeroutput">get_deleter()</code> may destroy *this.</p>
340<p><span class="bold"><strong>Postconditions</strong></span>: <code class="computeroutput">get() == p</code>. Note: The postcondition does not hold if the call to <code class="computeroutput">get_deleter()</code> destroys *this since <code class="computeroutput">this-&gt;get()</code> is no longer a valid expression.</p>
341<p><span class="bold"><strong>Remarks</strong></span>: This constructor shall not participate in overload resolution unless:</p>
342<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
343<li class="listitem"><p>If T is not an array type and Pointer is implicitly convertible to pointer.</p></li>
344<li class="listitem"><p>If T is an array type and Pointer is a more CV qualified pointer to element_type. </p></li>
345</ul></div>
346<p>
347</p>
348</li>
349<li class="listitem">
350<pre class="literallayout"><span class="keyword">void</span> <a name="id-1_3_26_20_14_3_1_1_6_10-bb"></a><span class="identifier">reset</span><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
351<p><span class="bold"><strong>Requires</strong></span>: The expression <code class="computeroutput">get_deleter()(get())</code> shall be well formed, shall have well-defined behavior, and shall not throw exceptions.</p>
352<p><span class="bold"><strong>Effects</strong></span>: assigns nullptr to the stored pointer, and then if the old value of the stored pointer, old_p, was not equal to nullptr, calls <code class="computeroutput">get_deleter()(old_p)</code>. Note: The order of these operations is significant because the call to <code class="computeroutput">get_deleter()</code> may destroy *this.</p>
353<p><span class="bold"><strong>Postconditions</strong></span>: <code class="computeroutput">get() == p</code>. Note: The postcondition does not hold if the call to <code class="computeroutput">get_deleter()</code> destroys *this since <code class="computeroutput">this-&gt;get()</code> is no longer a valid expression. </p>
354</li>
355<li class="listitem">
356<pre class="literallayout"><span class="keyword">void</span> <a name="id-1_3_26_20_14_3_1_1_6_11-bb"></a><span class="identifier">reset</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nullptr_t</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
357<p><span class="bold"><strong>Effects</strong></span>: Same as <code class="computeroutput">reset()</code> </p>
358</li>
359<li class="listitem">
360<pre class="literallayout"><span class="keyword">void</span> <a name="id-1_3_26_20_14_3_1_1_6_12-bb"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="unique_ptr.html" title="Class template unique_ptr">unique_ptr</a> <span class="special">&amp;</span> u<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
361<p><span class="bold"><strong>Requires</strong></span>: <code class="computeroutput">get_deleter()</code> shall be swappable and shall not throw an exception under swap.</p>
362<p><span class="bold"><strong>Effects</strong></span>: Invokes swap on the stored pointers and on the stored deleters of *this and u. </p>
363</li>
364</ol></div>
365</div>
366</div>
367</div>
368<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
369<td align="left"></td>
370<td align="right"><div class="copyright-footer">Copyright © 2008-2014 Ion Gaztanaga<p>
371        Distributed under the Boost Software License, Version 1.0. (See accompanying
372        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>)
373      </p>
374</div></td>
375</tr></table>
376<hr>
377<div class="spirit-nav">
378<a accesskey="p" href="../has_trivi_1_3_26_20_13_1_2.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../move/reference.html#header.boost.move.unique_ptr_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="swap.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
379</div>
380</body>
381</html>
382