Update documentation in make_shared_array.html

This commit is contained in:
Glen Fernandes
2017-03-10 10:21:21 -05:00
committed by GitHub
parent 650537da60
commit fac6fbe3cf

View File

@@ -1,278 +1,365 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>make_shared and allocate_shared for arrays</title> <meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>allocate_shared and make_shared for arrays</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>allocate_shared and make_shared for arrays</h1>
width="277" align="middle" border="0">make_shared and allocate_shared <div id="navigation">
for arrays</h1> <ul>
<p><a href="#introduction">Introduction</a><br> <li><a href="#introduction">Introduction</a></li>
<a href="#synopsis">Synopsis</a><br> <li><a href="#synopsis">Synopsis</a></li>
<a href="#common">Common Requirements</a><br> <li><a href="#requirements">Common Requirements</a></li>
<a href="#functions">Free Functions</a><br> <li><a href="#functions">Free Functions</a></li>
<a href="#history">History</a><br> <li><a href="#history">History</a></li>
<a href="#references">References</a></p> <li><a href="#references">References</a></li>
<h2><a name="introduction">Introduction</a></h2> </ul>
<p>Originally the Boost function templates <code>make_shared</code> and </div>
<code>allocate_shared</code> were for efficient allocation of shared <div id="introduction">
objects only. There was a need to have efficient allocation of <h2>Introduction</h2>
shared arrays. One criticism of class template <code>shared_array</code> <p>
was always the lack of a <a href="make_shared.html">make_shared</a> Originally the Boost function templates <code>allocate_shared</code> and
utility which ensures only a single allocation.</p> <code>make_shared</code> were for efficient allocation of shared scalar
<p>The header files &lt;boost/smart_ptr/make_shared_array.hpp&gt; and objects only. There was a need to have efficient allocation of shared
&lt;boost/smart_ptr/allocate_shared_array.hpp&gt; provide function arrays. One criticism of class template <code>shared_array</code>
templates, overloads of <code>make_shared</code> and was always the lack of a utility like <code>make_shared</code> that
<code>allocate_shared</code> for array types, to address this need. uses only a single allocation.
<code>make_shared</code> uses the global operator <code>new</code> to </p>
allocate memory, whereas <code>allocate_shared</code> uses an <p>
user-supplied allocator, allowing finer control.</p> The header files &lt;boost/smart_ptr/allocate_shared_array.hpp&gt; and
<h2><a name="synopsis">Synopsis</a></h2> &lt;boost/smart_ptr/make_shared_array.hpp&gt; provide function
<pre>namespace boost { templates, overloads of <code>allocate_shared</code> and
template&lt;class U&gt; // U is T[] <code>make_shared</code> for array types, to address this need.
shared_ptr&lt;U&gt; <a href="#functions">make_shared</a>(size_t size); <code>allocate_shared</code> uses a user-supplied allocator for
allocation, while <code>make_shared</code> uses
template&lt;class U, class A&gt; // U is T[] <code>allocate_shared</code> with the Default Allocator.
shared_ptr&lt;U&gt; <a href="#functions">allocate_shared</a>(const A&amp; allocator, size_t size); </p>
</div>
template&lt;class U&gt; // U is T[N] <div id="synopsis">
shared_ptr&lt;U&gt; <a href="#functions">make_shared</a>(); <h2>Synopsis</h2>
<div>
template&lt;class U, class A&gt; // U is T[N] <h3>Header &lt;boost/smart_ptr/allocate_shared_array.hpp&gt;</h3>
shared_ptr&lt;U&gt; <a href="#functions">allocate_shared</a>(const A&amp; allocator); <code>namespace boost {</code>
template&lt;class U&gt; // U is T[]
shared_ptr&lt;U&gt; <a href="#functions">make_shared</a>(size_t size, const T&amp; value);
template&lt;class U, class A&gt; // U is T[]
shared_ptr&lt;U&gt; <a href="#functions">allocate_shared</a>(const A&amp; allocator, size_t size, const T&amp; value);
template&lt;class U&gt; // U is T[N]
shared_ptr&lt;U&gt; <a href="#functions">make_shared</a>(const T&amp; value);
template&lt;class U, class A&gt; // U is T[N]
shared_ptr&lt;U&gt; <a href="#functions">allocate_shared</a>(const A&amp; allocator, const T&amp; value);
template&lt;class U&gt; // U is T[]
shared_ptr&lt;U&gt; <a href="#functions">make_shared_noinit</a>(size_t size);
template&lt;class U, class A&gt; // U is T[]
shared_ptr&lt;U&gt; <a href="#functions">allocate_shared_noinit</a>(const A&amp; allocator, size_t size);
template&lt;class U&gt; // U is T[N]
shared_ptr&lt;U&gt; <a href="#functions">make_shared_noinit</a>();
template&lt;class U, class A&gt; // U is T[N]
shared_ptr&lt;U&gt; <a href="#functions">allocate_shared_noinit</a>(const A&amp; allocator);
}</pre>
<h2><a name="common">Common Requirements</a></h2>
<pre>template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared(<em>args</em>);</pre>
<pre>template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, <em>args</em>);</pre>
<pre>template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared_noinit(<em>args</em>);</pre>
<pre>template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared_noinit(const A&amp; allocator, <em>args</em>);</pre>
<blockquote> <blockquote>
<p><b>Requires:</b> <code>U</code> is of the form <code>T[]</code> or <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<code>T[N]</code>. <code>A</code> shall be an <em>Allocator</em>, as <a href="#functions">allocate_shared</a>(const A&amp; a,
described in section 17.6.3.5 [<strong>Allocator std::size_t n);</code>
requirements</strong>] of the C++ Standard. The copy constructor and </blockquote>
destructor of <code>A</code> shall not throw exceptions.</p>
<p><b>Effects:</b> Allocates memory for an object of type <code>U</code>
(or <code>T[size]</code> when <code>U</code> is <code>T[]</code>,
where <code>size</code> is determined from <code><em>args</em></code>
as specified by the concrete overload). The object is initialized as
specified by the concrete overload. The templates
<code>allocate_shared</code> and <code>allocate_shared_noinit</code>
use a copy of <code>allocator</code> to allocate memory. If an
exception is thrown, the functions have no effect.</p>
<p><b>Returns:</b> A <code>shared_ptr</code> instance that stores and
owns the address of the newly constructed object.</p>
<p><b>Postconditions:</b> <code>r.get() != 0 &amp;&amp;
r.use_count() == 1</code>, where <code>r</code> is the return
value.</p>
<p><b>Throws:</b> <code>bad_alloc</code>, an exception thrown from
<code>A::allocate</code>, or from the initialization of the
object.</p>
<p><b>Remarks:</b></p>
<blockquote> <blockquote>
<p>This implementation performs no more than one memory <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
allocation. This provides efficiency to equivalent to an intrusive <a href="#functions">allocate_shared</a>(const A&amp; a);</code>
smart pointer.</p> </blockquote>
<p>When an object of an array type <code>T</code> is specified to be <blockquote>
initialized to a value of the same type <code>value</code>, this <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
shall be interpreted to mean that each array element of the object <a href="#functions">allocate_shared</a>(const A&amp; a, std::size_t n,
is initialized to the corresponding element from const <em>E</em>&amp; v);</code>
<code>value</code>.</p> </blockquote>
<p>When an object of an array type is specified to be <blockquote>
value-initialized, this shall be interpreted to mean that each <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
array element of the object is value-initialized.</p> <a href="#functions">allocate_shared</a>(const A&amp; a,
<p>Array elements are initialized in ascending order of their const <em>E</em>&amp; v);</code>
addresses.</p> </blockquote>
<p>When a subobject of a non-array type <code>T</code> is specified to <blockquote>
be initialized to a value <code>value</code>, <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<code>make_shared</code> shall perform this initialization via the <a href="#functions">allocate_shared_noinit</a>(const A&amp; a,
expression <code>::new(ptr) T(value)</code>, where <code>ptr</code> std::size_t n);</code>
has type <code>void*</code> and points to storage suitable to hold </blockquote>
an object of type <code>T</code>.</p> <blockquote>
<p>When a subobject of non-array type <code>T</code> is specified to <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
be initialized to a value <code>value</code>, <a href="#functions">allocate_shared_noinit</a>(const A&amp; a);</code>
<code>allocate_shared</code> shall perform this initialization via </blockquote>
the expression <code>allocator_traits&lt;A2&gt;::construct(a2, ptr, <code>}</code>
value)</code>, where <code>ptr</code> points to storage suitable to </div>
hold an object of type <code>T</code> and <code>a2</code> of type A2 <div>
is a rebound copy of the allocator <code>allocator</code> passed to <h3>Header &lt;boost/smart_ptr/make_shared_array.hpp&gt;</h3>
<code>allocate_shared</code> such that its <code>value_type</code> <code>namespace boost {</code>
is <code>T</code>.</p> <blockquote>
<p>When a subobject of non-array type <code>T</code> is specified to <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
be value-initialized, <code>make_shared</code> shall perform this <a href="#functions">make_shared</a>(std::size_t n);</code>
initialization via the expression <code>::new(ptr) T()</code>, where </blockquote>
<code>ptr</code> has type <code>void*</code> and points to storage <blockquote>
suitable to hold an object of type <code>T</code>.</p> <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<p>When a subobject of non-array type <code>T</code> is specified to <a href="#functions">make_shared</a>();</code>
be value-initialized, <code>allocate_shared</code> shall perform </blockquote>
this initialization via the expression <blockquote>
<code>allocator_traits&lt;A2&gt;::construct(a2, ptr)</code>, where <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<code>ptr</code> points to storage suitable to hold an object <a href="#functions">make_shared</a>(std::size_t n,
of type <code>T</code> and <code>a2</code> of type A2 is a rebound const <em>E</em>&amp; v);</code>
copy of the allocator <code>allocator</code> passed to </blockquote>
<code>allocate_shared</code> such that its <code>value_type</code> <blockquote>
is <code>T</code>.</p> <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<p>When a subobject of non-array type <code>T</code> is specified to <a href="#functions">make_shared</a>(const <em>E</em>&amp; v);</code>
be default-initialized, <code>make_shared_noinit</code> and </blockquote>
<code>allocate_shared_noinit</code> shall perform this <blockquote>
initialization via the expression <code>::new(ptr) T</code>, where <code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<code>ptr</code> has type <code>void*</code> and points to storage <a href="#functions">make_shared_noinit</a>(std::size_t n);</code>
suitable to hold an object of type <code>T</code>.</p> </blockquote>
<p>When the lifetime of the object managed by the return value ends, <blockquote>
<code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<a href="#functions">make_shared_noinit</a>();</code>
</blockquote>
<code>}</code>
</div>
</div>
<div id="requirements">
<h2>Common Requirements</h2>
<h3><code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<a href="#functions">allocate_shared</a>(const A&amp; a,
<em>args</em>);</code></h3>
<dl>
<dt><strong>Requires:</strong></dt>
<dd><code>T</code> is of the form <code>E[N]</code> or
<code>E[]</code>. <code>A</code> shall be an <em>Allocator</em>, as
described in section 17.6.3.5 [Allocator requirements] of the C++
Standard. The copy constructor and destructor of <code>A</code> shall
not throw exceptions.</dd>
<dt><strong>Effects:</strong></dt>
<dd>Allocates storage for an object of type <code>E</code> (or
<code>E[size]</code> when <code>T</code> is <code>E[]</code>, where
<code>size</code> is determined from <code>args</code> as specified by
the concrete overload). A copy of the allocator is used to allocate
storage. The storage is initialized as specified by the concrete
overload. If an exception is thrown, the functions have no effect.</dd>
<dt><strong>Returns:</strong></dt>
<dd>A <code>shared_ptr</code> instance that stores and owns the address
of the newly allocated and constructed object.</dd>
<dt><strong>Postconditions:</strong></dt>
<dd><code>r.get() != 0</code> and <code>r.use_count() == 1</code>,
where <code>r</code> is the return value.</dd>
<dt><strong>Throws:</strong></dt>
<dd>An exception thrown from <code>A::allocate()</code>, or from the
initialization of the object.</dd>
<dt><strong>Remarks:</strong></dt>
<dd>
<ul>
<li>This implementation performs no more than one memory allocation.
This provides efficiency to equivalent to an intrusive smart
pointer.</li>
<li>When an object of an array type <code>T</code> is specified to be
initialized to a value of the same type <code>v</code>, this shall be
interpreted to mean that each array element of the object is initialized
to the corresponding element from <code>v</code>.</li>
<li>When an object of an array type <code>T</code> is specified to be
value-initialized, this shall be interpreted to mean that each array
element of the object is value-initialized.</li>
<li>Array elements are initialized in ascending order of their
addresses.</li>
<li>When a subobject of a scalar type <code>S</code> is specified to
be initialized to a value <code>v</code>, <code>allocate_shared</code>
shall perform this initialization via the expression
<code>std::allocator_traits&lt;A&gt;::construct(b, p, v)</code>, where
<code>p</code> points to storage suitable to hold an object of type
<code>S</code> and <code>b</code> of is a copy of the allocator
<code>a</code> passed to <code>allocate_shared</code> such that its
<code>value_type</code> is <code>S</code>.</li>
<li>When a subobject of scalar type <code>S</code> is specified to be
value-initialized, <code>allocate_shared</code> shall perform this
initialization via the expression
<code>std::allocator_traits&lt;A&gt;::construct(b, p)</code>, where
<code>p</code> points to storage suitable to hold an object
of type <code>S</code> and <code>b</code> is a copy of the allocator
<code>a</code> passed to <code>allocate_shared</code> such that its
<code>value_type</code> is <code>S</code>.</li>
<li>When a subobject of scalar type <code>S</code> is specified to be
default-initialized, <code>allocate_shared_noinit</code> shall perform
this initialization via the expression <code>::new(p) S</code>, where
<code>p</code> has type <code>void*</code> and points to storage
suitable to hold an object of type <code>S</code>.</li>
<li>When the lifetime of the object managed by the return value ends,
or when the initialization of an array element throws an exception, or when the initialization of an array element throws an exception,
the initialized elements should be destroyed in the reverse order the initialized elements should be destroyed in the reverse order
of their construction.</p> of their construction.</li>
</blockquote> </ul>
<p><b>Notes:</b> These functions will typically allocate more memory </dd>
than <code>sizeof(U)</code> to allow for internal bookkeeping <dt><strong>Notes:</strong></dt>
structures such as the reference counts.</p> <dd>These functions will typically allocate more memory than the size of
</blockquote> <code>sizeof(E)</code> to allow for internal bookkeeping structures such
<h2><a name="functions">Free Functions</a></h2> as the reference counts.</dd>
<pre>template&lt;class U&gt; </dl>
shared_ptr&lt;U&gt; make_shared(size_t size);</pre> </div>
<pre>template&lt;class U, class A&gt; <div id="functions">
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, size_t size);</pre> <h2>Free Functions</h2>
<blockquote> <div>
<p><b>Returns:</b> A <code>shared_ptr</code> to a value-initialized <h3><code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
object of type <code>T[size]</code>.</p> allocate_shared(const A&amp; a, std::size_t n);</code></h3>
<p><b>Remarks:</b> These overloads 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>shared_ptr</code> to a value-initialized object of type
<blockquote> <code>E[size]</code>.</dd>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared&lt;int[]&gt;(size);</pre> <dt><strong>Remarks:</strong></dt>
<pre>boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared&lt;int[][2]&gt;(size);</pre> <dd>This overload shall only participate in overload resolution when
</blockquote> <code>T</code> is of the form <code>E[]</code>.</dd>
</blockquote> </dl>
<pre>template&lt;class U&gt; </div>
shared_ptr&lt;U&gt; make_shared();</pre> <div>
<pre>template&lt;class U, class A&gt; <h3><code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator);</pre> allocate_shared(const A&amp; a);</code></h3>
<blockquote> <dl>
<p><b>Returns:</b> A <code>shared_ptr</code> to a value-initialized <dt><strong>Returns:</strong></dt>
object of type <code>T[N]</code>.</p> <dd>A <code>shared_ptr</code> to a value-initialized object of type
<p><b>Remarks:</b> These overloads shall only participate in overload <code>E[N]</code>.</dd>
resolution when <code>U</code> is of the form <code>T[N]</code>.</p> <dt><strong>Remarks:</strong></dt>
<p><b>Examples:</b></p> <dd>This overload shall only participate in overload resolution when
<blockquote> <code>T</code> is of the form <code>E[N]</code>.</dd>
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared&lt;int[8]&gt;();</pre> </dl>
<pre>boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared&lt;int[4][2]&gt;();</pre> </div>
</blockquote> <div>
</blockquote> <h3><code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<pre>template&lt;class U&gt; allocate_shared(const A&amp; a, std::size_t n,
shared_ptr&lt;U&gt; make_shared(size_t size, const T&amp; value);</pre> const <em>E</em>&amp; v);</code></h3>
<pre>template&lt;class U, class A&gt; <dl>
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, size_t size, const T&amp; value);</pre> <dt><strong>Returns:</strong></dt>
<blockquote> <dd>A <code>shared_ptr</code> to an object of type
<p><b>Returns:</b> A <code>shared_ptr</code> to an object of type <code>E[size]</code>, where each array element of type <code>E</code> is
<code>T[size]</code>, where each array element of type <code>T</code> initialized to <code>v</code>.</dd>
is initialized to <code>value</code>.</p> <dt><strong>Remarks:</strong></dt>
<p><b>Remarks:</b> These overloads shall only participate in overload <dd>This overload shall only participate in overload resolution when
resolution when <code>U</code> is of the form <code>T[]</code>.</p> <code>T</code> is of the form <code>E[]</code>.</dd>
<p><b>Examples:</b></p> </dl>
<blockquote> </div>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared&lt;int[]&gt;(size, 1);</pre> <div>
<pre>boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared&lt;int[][2]&gt;(size, {1, 2});</pre> <h3><code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
</blockquote> allocate_shared(const A&amp; a, const <em>E</em>&amp; v);</code></h3>
</blockquote> <dl>
<pre>template&lt;class U&gt; <dt><strong>Returns:</strong></dt>
shared_ptr&lt;U&gt; make_shared(const T&amp; value);</pre> <dd>A <code>shared_ptr</code> to an object of type <code>E[N]</code>,
<pre>template&lt;class U, class A&gt; where each array element of type <code>E</code> is initialized to
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, const T&amp; value);</pre> <code>v</code>.</dd>
<blockquote> <dt><strong>Remarks:</strong></dt>
<p><b>Returns:</b> A <code>shared_ptr</code> to an object of type <dd>This overload shall only participate in overload resolution when
<code>T[N]</code>, where each array element of type <code>T</code> is <code>T</code> is of the form <code>E[N]</code>.</dd>
initialized to <code>value</code>.</p> </dl>
<p><b>Remarks:</b> These overloads shall only participate in overload </div>
resolution when <code>U</code> is of the form <code>T[N]</code>.</p> <div>
<p><b>Examples:</b></p> <h3><code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<blockquote> allocate_shared_noinit(const A&amp; a, std::size_t n);</code></h3>
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared&lt;int[8]&gt;(1);</pre> <dl>
<pre>boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared&lt;int[4][2]&gt;({1, 2});</pre> <dt><strong>Returns:</strong></dt>
</blockquote> <dd>A <code>shared_ptr</code> to a default-initialized object of type
</blockquote> <code>E[size]</code>.</dd>
<pre>template&lt;class U&gt; <dt><strong>Remarks:</strong></dt>
shared_ptr&lt;U&gt; make_shared_noinit(size_t size);</pre> <dd>This overload shall only participate in overload resolution when
<pre>template&lt;class U, class A&gt; <code>T</code> is of the form <code>E[]</code>.</dd>
shared_ptr&lt;U&gt; allocate_shared_noinit(const A&amp; allocator, size_t size);</pre> </dl>
<blockquote> </div>
<p><b>Returns:</b> A <code>shared_ptr</code> to a default-initialized <div>
object of type <code>T[size]</code>.</p> <h3><code>template&lt;class T, class A&gt;<br>shared_ptr&lt;T&gt;
<p><b>Remarks:</b> These overloads shall only participate in overload allocate_shared_noinit(const A&amp; a);</code></h3>
resolution when <code>U</code> is of the form <code>T[]</code>.</p> <dl>
<p><b>Examples:</b></p> <dt><strong>Returns:</strong></dt>
<blockquote> <dd>A <code>shared_ptr</code> to a default-initialized object of type
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared_noinit&lt;int[]&gt;(size);</pre> <code>E[N]</code>.</dd>
<pre>boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared_noinit&lt;int[][2]&gt;(size);</pre> <dt><strong>Remarks:</strong></dt>
</blockquote> <dd>This overload shall only participate in overload resolution when
</blockquote> <code>T</code> is of the form <code>E[N]</code>.</dd>
<pre>template&lt;class U&gt; </dl>
shared_ptr&lt;U&gt; make_shared_noinit();</pre> </div>
<pre>template&lt;class U, class A&gt; <div>
shared_ptr&lt;U&gt; allocate_shared_noinit(const A&amp; allocator);</pre> <h3><code>template&lt;class T&gt;<br>shared_ptr&lt;T&gt;
<blockquote> make_shared(std::size_t n);</code></h3>
<p><b>Returns:</b> A <code>shared_ptr</code> to a default-initialized <dl>
object of type <code>T[N]</code>.</p> <dt><strong>Returns:</strong></dt>
<p><b>Remarks:</b> These overloads shall only participate in overload <dd><code>allocate_shared&lt;T&gt;(std::allocator&lt;<em>S<!--
resolution when <code>U</code> is of the form <code>T[N]</code>.</p> --></em>&gt;(), n);</code></dd>
<p><b>Examples:</b></p> <dt><strong>Remarks:</strong></dt>
<blockquote> <dd>This overload shall only participate in overload resolution when
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared_noinit&lt;int[8]&gt;();</pre> <code>T</code> is of the form <code>E[]</code>.</dd>
<pre>boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared_noinit&lt;int[4][2]&gt;();</pre> </dl>
</blockquote> </div>
</blockquote> <div>
<h2><a name="history">History</a></h2> <h3><code>template&lt;class T&gt;<br>shared_ptr&lt;T&gt;
<p>February 2017. Glen Fernandes rewrote allocate_shared and make_shared make_shared();</code></h3>
for a more optimal and more maintainable implementation.</p> <dl>
<p>February 2014. Glen Fernandes updated overloads of make_shared and <dt><strong>Returns:</strong></dt>
allocate_shared to conform to the specification in C++ standard paper <dd><code>allocate_shared&lt;T&gt;(std::allocator&lt;<em>S<!--
--></em>&gt;());</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[N]</code>.</dd>
</dl>
</div>
<div>
<h3><code>template&lt;class T&gt;<br>shared_ptr&lt;T&gt;
make_shared(std::size_t n, const <em>E</em>&amp; v);</code></h3>
<dl>
<dt><strong>Returns:</strong></dt>
<dd><code>allocate_shared&lt;T&gt;(std::allocator&lt;<em>S<!--
--></em>&gt;(), n, v);</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>
<h3><code>template&lt;class T&gt;<br>shared_ptr&lt;T&gt;
make_shared(const <em>E</em>&amp; v);</code></h3>
<dl>
<dt><strong>Returns:</strong></dt>
<dd><code>allocate_shared&lt;T&gt;(std::allocator&lt;<em>S<!--
--></em>&gt;(), v);</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[N].</code></dd>
</dl>
</div>
<div>
<h3><code>template&lt;class T&gt;<br>shared_ptr&lt;T&gt;
make_shared_noinit(std::size_t n);</code></h3>
<dl>
<dt><strong>Returns:</strong></dt>
<dd><code>allocate_shared_noinit&lt;T&gt;(std::allocator&lt;<em>S<!--
--></em>&gt;(), n);</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>
<h3><code>template&lt;class T&gt;<br>shared_ptr&lt;T&gt;
make_shared_noinit();</code></h3>
<dl>
<dt><strong>Returns:</strong></dt>
<dd><code>allocate_shared_noinit&lt;T&gt;(std::allocator&lt;<em>S<!--
--></em>&gt;());</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[N]</code>.</dd>
</dl>
</div>
</div>
<div id="history">
<h2>History</h2>
<dl>
<dt><strong>Boost 1.64</strong></dt>
<dd>Glen Fernandes rewrote allocate_shared and make_shared for a more
optimal and more maintainable implementation.</dd>
<dt><strong>Boost 1.56</strong></dt>
<dd>Glen Fernandes updated overloads of make_shared and allocate_shared
to conform to the specification in C++ standard paper
<a href="#N3870">N3870</a>, including resolving C++ standard library <a href="#N3870">N3870</a>, including resolving C++ standard library
defect report <a href="#2070">DR2070</a>.</p> defect report <a href="#dr2070">DR 2070</a>.</dd>
<p>November 2012. Glen Fernandes contributed implementations of <dt><strong>Boost 1.53</strong></dt>
make_shared and allocate_shared for arrays.</p> <dd>Glen Fernandes contributed implementations of make_shared and
<h2><a name="references">References</a></h2> allocate_shared for arrays.</dd>
<p><a name="N3870">N3870</a>, </dl>
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3870.html"> </div>
<div id="references">
<h2>References</h2>
<ol>
<li id="N3870"><strong>N3870</strong>, <a href=
"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3870.html">
Extending make_shared to Support Arrays, Revision 1</a>, Peter Dimov Extending make_shared to Support Arrays, Revision 1</a>, Peter Dimov
&amp; Glen Fernandes, January, 2014.</p> &amp; Glen Fernandes, January, 2014.</li>
<p><a name="DR2070">DR2070</a>, <li id="dr2070"><strong>DR 2070</strong>,
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html"> <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html">
allocate_shared should use allocator_traits&lt;A&gt;::construct</a>, allocate_shared should use allocator_traits&lt;A&gt;::construct</a>,
Jonathan Wakely, July, 2011.</p> Jonathan Wakely, July, 2011.</li>
</ol>
</div>
<hr> <hr>
<p>$Date$</p> Copyright 2012-2017 Glen Fernandes. Distributed under the
<p><small>Copyright 2012-2014 Glen Fernandes. Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License,
Boost Software License, Version 1.0. See accompanying file Version 1.0</a>.
<a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
<a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt</a>.</small></p>
</body> </body>
</html> </html>