mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-08-02 14:14:27 +02:00
Merge branch 'develop'
This commit is contained in:
@@ -68,13 +68,13 @@
|
|||||||
}</pre>
|
}</pre>
|
||||||
<h2><a name="common">Common Requirements</a></h2>
|
<h2><a name="common">Common Requirements</a></h2>
|
||||||
<pre>template<class U>
|
<pre>template<class U>
|
||||||
shared_ptr<U> make_shared(<em>args</em>);
|
shared_ptr<U> make_shared(<em>args</em>);</pre>
|
||||||
template<class U, class A>
|
<pre>template<class U, class A>
|
||||||
shared_ptr<U> allocate_shared(const A& allocator, <em>args</em>);
|
shared_ptr<U> allocate_shared(const A& allocator, <em>args</em>);</pre>
|
||||||
template<class U>
|
<pre>template<class U>
|
||||||
shared_ptr<U> make_shared_noinit(<em>args</em>);
|
shared_ptr<U> make_shared_noinit(<em>args</em>);</pre>
|
||||||
template<class U, class A>
|
<pre>template<class U, class A>
|
||||||
shared_ptr<U> allocate_shared_noinit(const A& allocator, <em>args</em>);</pre>
|
shared_ptr<U> allocate_shared_noinit(const A& allocator, <em>args</em>);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Requires:</b> <code>U</code> is of the form <code>T[]</code> or
|
<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
|
<code>T[N]</code>. <code>A</code> shall be an <em>Allocator</em>, as
|
||||||
@@ -158,9 +158,9 @@ template<class U, class A>
|
|||||||
</blockquote>
|
</blockquote>
|
||||||
<h2><a name="functions">Free Functions</a></h2>
|
<h2><a name="functions">Free Functions</a></h2>
|
||||||
<pre>template<class U>
|
<pre>template<class U>
|
||||||
shared_ptr<U> make_shared(size_t size);
|
shared_ptr<U> make_shared(size_t size);</pre>
|
||||||
template<class U, class A>
|
<pre>template<class U, class A>
|
||||||
shared_ptr<U> allocate_shared(const A& allocator, size_t size);</pre>
|
shared_ptr<U> allocate_shared(const A& allocator, size_t size);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A <code>shared_ptr</code> to a value-initialized
|
<p><b>Returns:</b> A <code>shared_ptr</code> to a value-initialized
|
||||||
object of type <code>T[size]</code>.</p>
|
object of type <code>T[size]</code>.</p>
|
||||||
@@ -168,14 +168,14 @@ template<class U, class A>
|
|||||||
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
||||||
<p><b>Examples:</b></p>
|
<p><b>Examples:</b></p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(size);
|
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(size);</pre>
|
||||||
boost::shared_ptr<int[][2]> a2 = boost::make_shared<int[][2]>(size);</pre>
|
<pre>boost::shared_ptr<int[][2]> a2 = boost::make_shared<int[][2]>(size);</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre>template<class U>
|
<pre>template<class U>
|
||||||
shared_ptr<U> make_shared();
|
shared_ptr<U> make_shared();</pre>
|
||||||
template<class U, class A>
|
<pre>template<class U, class A>
|
||||||
shared_ptr<U> allocate_shared(const A& allocator);</pre>
|
shared_ptr<U> allocate_shared(const A& allocator);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A <code>shared_ptr</code> to a value-initialized
|
<p><b>Returns:</b> A <code>shared_ptr</code> to a value-initialized
|
||||||
object of type <code>T[N]</code>.</p>
|
object of type <code>T[N]</code>.</p>
|
||||||
@@ -183,14 +183,14 @@ template<class U, class A>
|
|||||||
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
||||||
<p><b>Examples:</b></p>
|
<p><b>Examples:</b></p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared<int[8]>();
|
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared<int[8]>();</pre>
|
||||||
boost::shared_ptr<int[4][2]> a2 = boost::make_shared<int[4][2]>();</pre>
|
<pre>boost::shared_ptr<int[4][2]> a2 = boost::make_shared<int[4][2]>();</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre>template<class U>
|
<pre>template<class U>
|
||||||
shared_ptr<U> make_shared(size_t size, const T& value);
|
shared_ptr<U> make_shared(size_t size, const T& value);</pre>
|
||||||
template<class U, class A>
|
<pre>template<class U, class A>
|
||||||
shared_ptr<U> allocate_shared(const A& allocator, size_t size, const T& value);</pre>
|
shared_ptr<U> allocate_shared(const A& allocator, size_t size, const T& value);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> 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>T[size]</code>, where each array element of type <code>T</code>
|
<code>T[size]</code>, where each array element of type <code>T</code>
|
||||||
@@ -199,14 +199,14 @@ template<class U, class A>
|
|||||||
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
||||||
<p><b>Examples:</b></p>
|
<p><b>Examples:</b></p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(size, 1);
|
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(size, 1);</pre>
|
||||||
boost::shared_ptr<int[][2]> a2 = boost::make_shared<int[][2]>(size, {1, 2});</pre>
|
<pre>boost::shared_ptr<int[][2]> a2 = boost::make_shared<int[][2]>(size, {1, 2});</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre>template<class U>
|
<pre>template<class U>
|
||||||
shared_ptr<U> make_shared(const T& value);
|
shared_ptr<U> make_shared(const T& value);</pre>
|
||||||
template<class U, class A>
|
<pre>template<class U, class A>
|
||||||
shared_ptr<U> allocate_shared(const A& allocator, const T& value);</pre>
|
shared_ptr<U> allocate_shared(const A& allocator, const T& value);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> 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>T[N]</code>, where each array element of type <code>T</code> is
|
<code>T[N]</code>, where each array element of type <code>T</code> is
|
||||||
@@ -215,14 +215,14 @@ template<class U, class A>
|
|||||||
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
||||||
<p><b>Examples:</b></p>
|
<p><b>Examples:</b></p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared<int[8]>(1);
|
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared<int[8]>(1);</pre>
|
||||||
boost::shared_ptr<int[4][2]> a2 = boost::make_shared<int[4][2]>({1, 2});</pre>
|
<pre>boost::shared_ptr<int[4][2]> a2 = boost::make_shared<int[4][2]>({1, 2});</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre>template<class U>
|
<pre>template<class U>
|
||||||
shared_ptr<U> make_shared_noinit(size_t size);
|
shared_ptr<U> make_shared_noinit(size_t size);</pre>
|
||||||
template<class U, class A>
|
<pre>template<class U, class A>
|
||||||
shared_ptr<U> allocate_shared_noinit(const A& allocator, size_t size);</pre>
|
shared_ptr<U> allocate_shared_noinit(const A& allocator, size_t size);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A <code>shared_ptr</code> to a default-initialized
|
<p><b>Returns:</b> A <code>shared_ptr</code> to a default-initialized
|
||||||
object of type <code>T[size]</code>.</p>
|
object of type <code>T[size]</code>.</p>
|
||||||
@@ -230,14 +230,14 @@ template<class U, class A>
|
|||||||
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
||||||
<p><b>Examples:</b></p>
|
<p><b>Examples:</b></p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared_noinit<int[]>(size);
|
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared_noinit<int[]>(size);</pre>
|
||||||
boost::shared_ptr<int[][2]> a2 = boost::make_shared_noinit<int[][2]>(size);</pre>
|
<pre>boost::shared_ptr<int[][2]> a2 = boost::make_shared_noinit<int[][2]>(size);</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre>template<class U>
|
<pre>template<class U>
|
||||||
shared_ptr<U> make_shared_noinit();
|
shared_ptr<U> make_shared_noinit();</pre>
|
||||||
template<class U, class A>
|
<pre>template<class U, class A>
|
||||||
shared_ptr<U> allocate_shared_noinit(const A& allocator);</pre>
|
shared_ptr<U> allocate_shared_noinit(const A& allocator);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><b>Returns:</b> A <code>shared_ptr</code> to a default-initialized
|
<p><b>Returns:</b> A <code>shared_ptr</code> to a default-initialized
|
||||||
object of type <code>T[N]</code>.</p>
|
object of type <code>T[N]</code>.</p>
|
||||||
@@ -245,16 +245,17 @@ template<class U, class A>
|
|||||||
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
||||||
<p><b>Examples:</b></p>
|
<p><b>Examples:</b></p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared_noinit<int[8]>();
|
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared_noinit<int[8]>();</pre>
|
||||||
boost::shared_ptr<int[4][2]> a2 = boost::make_shared_noinit<int[4][2]>();</pre>
|
<pre>boost::shared_ptr<int[4][2]> a2 = boost::make_shared_noinit<int[4][2]>();</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h2><a name="history">History</a></h2>
|
<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
|
<p>February 2014. Glen Fernandes updated overloads of make_shared and
|
||||||
allocate_shared to conform to the specification in C++ standard paper
|
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 2070, and reduced the spatial overhead of the internal
|
defect report <a href="#2070">DR2070</a>.</p>
|
||||||
bookkeeping structures.</p>
|
|
||||||
<p>November 2012. Glen Fernandes contributed implementations of
|
<p>November 2012. Glen Fernandes contributed implementations of
|
||||||
make_shared and allocate_shared for arrays.</p>
|
make_shared and allocate_shared for arrays.</p>
|
||||||
<h2><a name="references">References</a></h2>
|
<h2><a name="references">References</a></h2>
|
||||||
@@ -262,6 +263,10 @@ boost::shared_ptr<int[4][2]> a2 = boost::make_shared_noinit<int[4][2]&g
|
|||||||
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3870.html">
|
<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
|
||||||
& Glen Fernandes, January, 2014.</p>
|
& 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<A>::construct</a>,
|
||||||
|
Jonathan Wakely, July, 2011.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>$Date$</p>
|
<p>$Date$</p>
|
||||||
<p><small>Copyright 2012-2014 Glen Fernandes. Distributed under the
|
<p><small>Copyright 2012-2014 Glen Fernandes. Distributed under the
|
||||||
|
@@ -136,6 +136,9 @@
|
|||||||
<p>Functions which destroy objects of the pointed to type are prohibited from
|
<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>
|
throwing exceptions by the <a href="#common_requirements">common requirements</a>.</p>
|
||||||
<h2><a name="History">History</a> and Acknowledgements</h2>
|
<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
|
<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
|
<b>allocate_shared</b> to conform to the specification in C++ standard paper
|
||||||
<a href="#D&F-14">[D&F-14]</a>, and implemented <b>make_unique</b> for
|
<a href="#D&F-14">[D&F-14]</a>, and implemented <b>make_unique</b> for
|
||||||
|
Reference in New Issue
Block a user