Update documentation in make_unique.html

This commit is contained in:
Glen Fernandes
2017-03-10 11:55:06 -05:00
committed by GitHub
parent fac6fbe3cf
commit 687d31b7c8

View File

@@ -1,150 +1,176 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>make_unique</title> <meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>make_unique</title>
</head> </head>
<body text="#000000" bgcolor="#ffffff" link="#0000ff" vlink="#0000ff"> <body>
<h1><img height="86" alt="boost.png (6897 bytes)" src="../../boost.png" <h1>make_unique</h1>
width="277" align="middle" border="0">make_unique</h1> <div id="navigation">
<p><a href="#introduction">Introduction</a><br> <ul>
<a href="#synopsis">Synopsis</a><br> <li><a href="#introduction">Introduction</a></li>
<a href="#common">Common Requirements</a><br> <li><a href="#synopsis">Synopsis</a></li>
<a href="#functions">Free Functions</a><br> <li><a href="#requirements">Common Requirements</a></li>
<a href="#history">History</a></p> <li><a href="#functions">Free Functions</a></li>
<h2><a name="introduction">Introduction</a></h2> <li><a href="#history">History</a></li>
<p>The header file &lt;boost/make_unique.hpp&gt; provides overloaded </ul>
function template <code>make_unique</code> for convenient creation of </div>
<code>unique_ptr</code> objects.</p> <div id="introduction">
<h2><a name="synopsis">Synopsis</a></h2> <h2>Introduction</h2>
<pre>namespace boost { <p>
template&lt;class U&gt; // U is not array The header file &lt;boost/make_unique.hpp&gt; provides overloads of
unique_ptr&lt;U&gt; <a href="#functions">make_unique</a>(); function template <code>make_unique</code> for convenient creation of
<code>std::unique_ptr</code> objects.
template&lt;class U, class... Args&gt; // U is not array </p>
unique_ptr&lt;U&gt; <a href="#functions">make_unique</a>(Args&amp;&amp;... args); </div>
<div id="synopsis">
template&lt;class U&gt; // U is not array <h2>Synopsis</h2>
unique_ptr&lt;U&gt; <a href="#functions">make_unique</a>(U&amp;&amp; value); <div>
<h3>Header &lt;boost/smart_ptr/make_unique.hpp&gt;</h3>
template&lt;class U&gt; // U is T[] <code>namespace boost {</code>
unique_ptr&lt;U&gt; <a href="#functions">make_unique</a>(size_t size); <blockquote>
<code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
template&lt;class U&gt; // U is not array <a href="#functions">make_unique</a>();</code>
unique_ptr&lt;U&gt; <a href="#functions">make_unique_noinit</a>(); </blockquote>
<blockquote>
template&lt;class U&gt; // U is T[] <code>template&lt;class T, class... Args&gt;<br>std::unique_ptr&lt;T&gt;
unique_ptr&lt;U&gt; <a href="#functions">make_unique_noinit</a>(size_t size); <a href="#functions">make_unique</a>(Args&amp;&amp;... args);</code>
}</pre> </blockquote>
<h2><a name="common">Common Requirements</a></h2> <blockquote>
<pre>template&lt;class U&gt; <code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
unique_ptr&lt;U&gt; make_unique(<em>args</em>);</pre> <a href="#functions">make_unique</a>(<em>T</em>&amp;&amp; value);</code>
<pre>template&lt;class U&gt; </blockquote>
unique_ptr&lt;U&gt; make_unique_noinit(<em>args</em>);</pre> <blockquote>
<blockquote> <code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
<p><b>Effects:</b> Allocates memory for an object of type <code>U</code> <a href="#functions">make_unique</a>(std::size_t size);</code>
(or <code>T[size]</code> when <code>U</code> is <code>T[]</code>, </blockquote>
where <code>size</code> is determined from <code>args</code> as <blockquote>
specified by the concrete overload). The object is initialized from <code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
<code>args</code> as specified by the concrete overload. If an <a href="#functions">make_unique_noinit</a>();</code>
exception is thrown, the functions have no effect.</p> </blockquote>
<p><b>Returns:</b> A <code>unique_ptr</code> instance that stores and <blockquote>
owns the address of the newly constructed object.</p> <code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
<p><b>Postconditions:</b> <code>r.get() != 0</code>, where <a href="#functions">make_unique_noinit</a>(std::size_t size);</code>
<code>r</code> is the return value.</p> </blockquote>
<p><b>Throws:</b> <code>bad_alloc</code>, or an exception thrown from <code>}</code>
the initialization of the object.</p> </div>
<p><b>Remarks:</b></p> </div>
<blockquote> <div id="requirements">
<p>When an object of a non-array type <code>T</code> is specified to <h2>Common Requirements</h2>
be initialized to a value <code>value</code>, or to <h3><code>template&lt;class T, <em>Args</em>&gt;<br>
<code>T(list...)</code>, where <code>list...</code> is a list of std::unique_ptr&lt;T&gt;
constructor arguments, <code>make_unique</code> shall perform this <a href="#functions">make_unique</a>(<em>args</em>);</code></h3>
initialization via the expression <code>new T(value)</code> or <dl>
<code>new T(list...)</code> respectively.</p> <dt><strong>Effects:</strong></dt>
<p>When an object of type <code>T</code> is specified to be <dd>Allocates storage for an object of type <code>T</code> (or
value-initialized, <code>make_unique</code> shall perform this <code>E[size]</code> when <code>T</code> is <code>E[]</code>, where
initialization via the expression <code>new T()</code>.</p> <code>size</code> is determined from <code>args</code> as specified by
<p>When an object of type <code>T</code> is specified to be the concrete overload). The storage is initialized from
default-initialized, <code>make_unique_noinit</code> shall perform <code>args</code> as specified by the concrete overload. If an exception
this initialization via the expression <code>new T</code>.</p> is thrown, the functions have no effect.</dd>
</blockquote> <dt><strong>Returns:</strong></dt>
</blockquote> <dd>A <code>std::unique_ptr</code> instance that stores and owns the
<h2><a name="functions">Free Functions</a></h2> address of the newly allocated and constructed object.</dd>
<pre>template&lt;class U, class... Args&gt; <dt><strong>Postconditions:</strong></dt>
unique_ptr&lt;U&gt; make_unique(Args&amp;&amp;... args);</pre> <dd><code>r.get() != 0</code>, where <code>r</code> is the return
<blockquote> value.</dd>
<p><b>Returns:</b> A unique_ptr to an object of type <code>U</code>, <dt><strong>Throws:</strong></dt>
initialized to <code>U(forward&lt;Args&gt;(args)...)</code>.</p> <dd><code>std::bad_alloc</code>, or an exception thrown from the
<p><b>Remarks:</b> This overload shall only participate in overload initialization of the object.</dd>
resolution when <code>U</code> is not an array type.</p> <dt><strong>Remarks:</strong></dt>
<p><b>Examples:</b></p> <dd>
<blockquote> <ul>
<pre>unique_ptr&lt;float&gt; p1 = boost::make_unique&lt;float&gt;();</pre> <li>When an object of a scalar type T is specified to be initialized to
<pre>unique_ptr&lt;point&gt; p2 = boost::make_unique&lt;point&gt;(x, y);</pre> a value <code>value</code>, or to <code>T(args...)</code>, where
</blockquote> <code>args...</code> is a list of constructor arguments,
</blockquote> <code>make_unique</code> shall perform this initialization via the
<pre>template&lt;class U&gt; expression <code>new T(value)</code> or <code>new T(args...)</code>
unique_ptr&lt;U&gt; make_unique(U&amp;&amp; value);</pre> respectively.</li>
<blockquote> <li>When an object of type <code>T</code> is specified to be
<p><b>Returns:</b> A unique_ptr to an object of type <code>U</code>, value-initialized, <code>make_unique</code> shall perform this
initialized to <code>move(value)</code>.</p> initialization via the expression <code>new T()</code>.</li>
<p><b>Remarks:</b> This overload shall only participate in overload <li>When an object of type <code>T</code> is specified to be
resolution when <code>U</code> is not an array type.</p> default-initialized, <code>make_unique_noinit</code> shall perform this
<p><b>Examples:</b></p> initialization via the expression <code>new T</code>.</li>
<blockquote> </ul>
<pre>unique_ptr&lt;string&gt; p1 = boost::make_unique&lt;string&gt;({'a', 'b'});</pre> </dd>
<pre>unique_ptr&lt;point&gt; p2 = boost::make_unique&lt;point&gt;({-10, 25});</pre> </dl>
</blockquote> </div>
</blockquote> <div id="functions">
<pre>template&lt;class U&gt; <h2>Free functions</h2>
unique_ptr&lt;U&gt; make_unique(size_t size);</pre> <div>
<blockquote> <h3><code>template&lt;class T, class... Args&gt;<br>
<p><b>Returns:</b> A unique_ptr to a value-initialized object of type std::unique_ptr&lt;T&gt;
<code>T[size]</code>.</p> make_unique(Args&amp;&amp;... args);</code></h3>
<p><b>Remarks:</b> This overload shall only participate in overload <dl>
resolution when <code>U</code> is of the form <code>T[]</code>.</p> <dt><strong>Returns:</strong></dt>
<p><b>Examples:</b></p> <dd>A <code>std::unique_ptr</code> to an object of type <code>T</code>,
<blockquote> initialized to <code>std::forward&lt;Args&gt;(args)...</code>.</dd>
<pre>unique_ptr&lt;double[]&gt; p1 = boost::make_unique&lt;double[]&gt;(4);</pre> <dt><strong>Remarks:</strong></dt>
<pre>unique_ptr&lt;int[][2]&gt; p2 = boost::make_unique&lt;int[][2]&gt;(2);</pre> <dd>This overload shall only participate in overload resolution when
</blockquote> <code>T</code> is not an array type.</dd>
</blockquote> </dl>
<pre>template&lt;class U&gt; </div>
unique_ptr&lt;U&gt; make_unique_noinit();</pre> <div>
<blockquote> <h3><code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
<p><b>Returns:</b> A unique_ptr to a default-initialized object of make_unique(<em>T</em>&amp;&amp; value);</code></h3>
type <code>U</code>.</p> <dl>
<p><b>Remarks:</b> This overload shall only participate in overload <dt><strong>Returns:</strong></dt>
resolution when <code>U</code> is not an array type.</p> <dd>A <code>std::unique_ptr</code> to an object of type <code>T</code>,
<p><b>Examples:</b></p> initialized to <code>std::move(value)</code>.</dd>
<blockquote> <dt><strong>Remarks:</strong></dt>
<pre>unique_ptr&lt;float&gt; p1 = boost::make_unique_noinit&lt;float&gt;();</pre> <dd>This overload shall only participate in overload resolution when
<pre>unique_ptr&lt;point&gt; p2 = boost::make_unique_noinit&lt;point&gt;();</pre> <code>T</code> is not an array type.</dd>
</blockquote> </dl>
</blockquote> </div>
<pre>template&lt;class U&gt; <div>
unique_ptr&lt;U&gt; make_unique_noinit(size_t size);</pre> <h3><code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
<blockquote> make_unique(std::size_t size);</code></h3>
<p><b>Returns:</b> A unique_ptr to a default-initialized object of <dl>
type <code>T[size]</code>.</p> <dt><strong>Returns:</strong></dt>
<p><b>Remarks:</b> This overload shall only participate in overload <dd>A <code>std::unique_ptr</code> to a value-initialized object of type
resolution when <code>U</code> is of the form <code>T[]</code>.</p> <code>E[size]</code>.</dd>
<p><b>Examples:</b></p> <dt><strong>Remarks:</strong></dt>
<blockquote> <dd>This overload shall only participate in overload resolution when
<pre>unique_ptr&lt;double[]&gt; p1 = boost::make_unique_noinit&lt;double[]&gt;(4);</pre> <code>T</code> is of the form <code>E[]</code>.</dd>
<pre>unique_ptr&lt;int[][2]&gt; p2 = boost::make_unique_noinit&lt;int[][2]&gt;(2);</pre> </dl>
</blockquote> </div>
</blockquote> <div>
<h2><a name="history">History</a></h2> <h3><code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
<p>January 2014. Glen Fernandes contributed implementations of make_unique_noinit();</code></h3>
make_unique for objects and arrays.</p> <dl>
<hr> <dt><strong>Returns:</strong></dt>
<p>$Date$</p> <dd>A <code>std::unique_ptr</code> to a default-initialized object of
<p><small>Copyright 2012-2014 Glen Fernandes. Distributed under the type <code>T</code>.</dd>
Boost Software License, Version 1.0. See accompanying file <dt><strong>Remarks:</strong></dt>
<a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <dd>This overload shall only participate in overload resolution when
<a href="http://www.boost.org/LICENSE_1_0.txt"> <code>T</code> is not an array type.</dd>
http://www.boost.org/LICENSE_1_0.txt</a>.</small></p> </dl>
</body> </div>
<div>
<h3><code>template&lt;class T&gt;<br>std::unique_ptr&lt;T&gt;
make_unique_noinit(std::size_t size);</code></h3>
<dl>
<dt><strong>Returns:</strong></dt>
<dd>A <code>std::unique_ptr</code> to a default-initialized object of
type <code>E[size]</code>.</dd>
<dt><strong>Remarks:</strong></dt>
<dd>This overload shall only participate in overload resolution when
<code>T</code> is of the form <code>E[]</code>.</dd>
</dl>
</div>
</div>
<div id="history">
<h2>History</h2>
<dl>
<dt><strong>Boost 1.56</strong></dt>
<dd>Glen Fernandes contributed implementations of make_unique for
scalars and arrays</dd>
</dl>
</div>
<hr>
Copyright 2012-2014 Glen Fernandes. Distributed under the
<a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License,
Version 1.0</a>.
</body>
</html> </html>