Merge branch 'develop'

This commit is contained in:
Glen Fernandes
2017-03-04 01:09:35 -05:00
2 changed files with 145 additions and 137 deletions

View File

@@ -68,13 +68,13 @@
}</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>);
template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, <em>args</em>);
template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared_noinit(<em>args</em>);
template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared_noinit(const A&amp; allocator, <em>args</em>);</pre>
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>
<p><b>Requires:</b> <code>U</code> is of the form <code>T[]</code> or
<code>T[N]</code>. <code>A</code> shall be an <em>Allocator</em>, as
@@ -158,9 +158,9 @@ template&lt;class U, class A&gt;
</blockquote>
<h2><a name="functions">Free Functions</a></h2>
<pre>template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared(size_t size);
template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, size_t size);</pre>
shared_ptr&lt;U&gt; make_shared(size_t size);</pre>
<pre>template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, size_t size);</pre>
<blockquote>
<p><b>Returns:</b> A <code>shared_ptr</code> to a value-initialized
object of type <code>T[size]</code>.</p>
@@ -168,14 +168,14 @@ template&lt;class U, class A&gt;
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
<p><b>Examples:</b></p>
<blockquote>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared&lt;int[]&gt;(size);
boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared&lt;int[][2]&gt;(size);</pre>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared&lt;int[]&gt;(size);</pre>
<pre>boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared&lt;int[][2]&gt;(size);</pre>
</blockquote>
</blockquote>
<pre>template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared();
template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator);</pre>
shared_ptr&lt;U&gt; make_shared();</pre>
<pre>template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator);</pre>
<blockquote>
<p><b>Returns:</b> A <code>shared_ptr</code> to a value-initialized
object of type <code>T[N]</code>.</p>
@@ -183,14 +183,14 @@ template&lt;class U, class A&gt;
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
<p><b>Examples:</b></p>
<blockquote>
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared&lt;int[8]&gt;();
boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared&lt;int[4][2]&gt;();</pre>
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared&lt;int[8]&gt;();</pre>
<pre>boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared&lt;int[4][2]&gt;();</pre>
</blockquote>
</blockquote>
<pre>template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared(size_t size, const T&amp; value);
template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, size_t size, const T&amp; value);</pre>
shared_ptr&lt;U&gt; make_shared(size_t size, const T&amp; value);</pre>
<pre>template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, size_t size, const T&amp; value);</pre>
<blockquote>
<p><b>Returns:</b> A <code>shared_ptr</code> to an object of type
<code>T[size]</code>, where each array element of type <code>T</code>
@@ -199,14 +199,14 @@ template&lt;class U, class A&gt;
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
<p><b>Examples:</b></p>
<blockquote>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared&lt;int[]&gt;(size, 1);
boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared&lt;int[][2]&gt;(size, {1, 2});</pre>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared&lt;int[]&gt;(size, 1);</pre>
<pre>boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared&lt;int[][2]&gt;(size, {1, 2});</pre>
</blockquote>
</blockquote>
<pre>template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared(const T&amp; value);
template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, const T&amp; value);</pre>
shared_ptr&lt;U&gt; make_shared(const T&amp; value);</pre>
<pre>template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared(const A&amp; allocator, const T&amp; value);</pre>
<blockquote>
<p><b>Returns:</b> A <code>shared_ptr</code> to an object of type
<code>T[N]</code>, where each array element of type <code>T</code> is
@@ -215,14 +215,14 @@ template&lt;class U, class A&gt;
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
<p><b>Examples:</b></p>
<blockquote>
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared&lt;int[8]&gt;(1);
boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared&lt;int[4][2]&gt;({1, 2});</pre>
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared&lt;int[8]&gt;(1);</pre>
<pre>boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared&lt;int[4][2]&gt;({1, 2});</pre>
</blockquote>
</blockquote>
<pre>template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared_noinit(size_t size);
template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared_noinit(const A&amp; allocator, size_t size);</pre>
shared_ptr&lt;U&gt; make_shared_noinit(size_t size);</pre>
<pre>template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared_noinit(const A&amp; allocator, size_t size);</pre>
<blockquote>
<p><b>Returns:</b> A <code>shared_ptr</code> to a default-initialized
object of type <code>T[size]</code>.</p>
@@ -230,14 +230,14 @@ template&lt;class U, class A&gt;
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
<p><b>Examples:</b></p>
<blockquote>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared_noinit&lt;int[]&gt;(size);
boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared_noinit&lt;int[][2]&gt;(size);</pre>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared_noinit&lt;int[]&gt;(size);</pre>
<pre>boost::shared_ptr&lt;int[][2]&gt; a2 = boost::make_shared_noinit&lt;int[][2]&gt;(size);</pre>
</blockquote>
</blockquote>
<pre>template&lt;class U&gt;
shared_ptr&lt;U&gt; make_shared_noinit();
template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared_noinit(const A&amp; allocator);</pre>
shared_ptr&lt;U&gt; make_shared_noinit();</pre>
<pre>template&lt;class U, class A&gt;
shared_ptr&lt;U&gt; allocate_shared_noinit(const A&amp; allocator);</pre>
<blockquote>
<p><b>Returns:</b> A <code>shared_ptr</code> to a default-initialized
object of type <code>T[N]</code>.</p>
@@ -245,16 +245,17 @@ template&lt;class U, class A&gt;
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
<p><b>Examples:</b></p>
<blockquote>
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared_noinit&lt;int[8]&gt;();
boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared_noinit&lt;int[4][2]&gt;();</pre>
<pre>boost::shared_ptr&lt;int[8]&gt; a1 = boost::make_shared_noinit&lt;int[8]&gt;();</pre>
<pre>boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared_noinit&lt;int[4][2]&gt;();</pre>
</blockquote>
</blockquote>
<h2><a name="history">History</a></h2>
<p>February 2017. Glen Fernandes rewrote allocate_shared and make_shared
for a more optimal and more maintainable implementation.</p>
<p>February 2014. 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
defect report 2070, and reduced the spatial overhead of the internal
bookkeeping structures.</p>
defect report <a href="#2070">DR2070</a>.</p>
<p>November 2012. Glen Fernandes contributed implementations of
make_shared and allocate_shared for arrays.</p>
<h2><a name="references">References</a></h2>
@@ -262,6 +263,10 @@ boost::shared_ptr&lt;int[4][2]&gt; a2 = boost::make_shared_noinit&lt;int[4][2]&g
<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
&amp; Glen Fernandes, January, 2014.</p>
<p><a name="DR2070">DR2070</a>,
<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>,
Jonathan Wakely, July, 2011.</p>
<hr>
<p>$Date$</p>
<p><small>Copyright 2012-2014 Glen Fernandes. Distributed under the

View File

@@ -136,6 +136,9 @@
<p>Functions which destroy objects of the pointed to type are prohibited from
throwing exceptions by the <a href="#common_requirements">common requirements</a>.</p>
<h2><a name="History">History</a> and Acknowledgements</h2>
<p>February 2017. Glen Fernandes rewrote <b>allocate_shared</b>
and <b>make_shared</b> for arrays for a more optimal and more
maintainable implementation.</p>
<p>February 2014. Glen Fernandes updated overloads of <b>make_shared</b> and
<b>allocate_shared</b> to conform to the specification in C++ standard paper
<a href="#D&amp;F-14">[D&amp;F-14]</a>, and implemented <b>make_unique</b> for