mirror of
https://github.com/boostorg/smart_ptr.git
synced 2026-02-03 22:05:04 +01:00
Update make_shared for arrays to address 2070
This updates make_shared and allocate_shared for arrays in accordance with report 2070 which requires that allocator_traits<A2>::construct(a2, ptr, ...) is used for construction and allocator_traits<A2>::destroy(a2, ptr) is used for destruction instead of placement new and destructor invocation.
This commit is contained in:
@@ -97,8 +97,6 @@ template<typename U, typename A>
|
||||
<p><b>Throws:</b> <code>bad_alloc</code>, an exception thrown from
|
||||
<code>A::allocate</code>, or from the initialization of the
|
||||
object.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p><b>Remarks:</b></p>
|
||||
<blockquote>
|
||||
<p>This implementation performs no more than one memory
|
||||
@@ -115,18 +113,34 @@ template<typename U, typename A>
|
||||
<p>Array elements are initialized in ascending order of their
|
||||
addresses.</p>
|
||||
<p>When a subobject of a non-array type <code>T</code> is specified to
|
||||
be initialized to a value <code>value</code>, or to
|
||||
<code>T(list...)</code>, where <code>list...</code> is a list of
|
||||
constructor arguments, <code>make_shared</code> shall perform this
|
||||
initialization via the expression <code>::new(ptr) T(value)</code>
|
||||
or <code>::new(ptr) T(list...)</code> respectively, where
|
||||
<code>ptr</code> has type <code>void*</code> and points to storage
|
||||
suitable to hold an object of type <code>T</code>.</p>
|
||||
be initialized to a value <code>value</code>,
|
||||
<code>make_shared</code> shall perform this initialization via the
|
||||
expression <code>::new(ptr) T(value)</code>, where <code>ptr</code>
|
||||
has type <code>void*</code> and points to storage suitable to hold
|
||||
an object of type <code>T</code>.</p>
|
||||
<p>When a subobject of non-array type <code>T</code> is specified to
|
||||
be initialized to a value <code>value</code>,
|
||||
<code>allocate_shared</code> shall perform this initialization via
|
||||
the expression <code>allocator_traits<A2>::construct(a2, ptr,
|
||||
value)</code>, where <code>ptr</code> points to storage suitable to
|
||||
hold an object of type <code>T</code> and <code>a2</code> of type A2
|
||||
is a rebound copy of the allocator <code>allocator</code> passed to
|
||||
<code>allocate_shared</code> such that its <code>value_type</code>
|
||||
is <code>T</code>.</p>
|
||||
<p>When a subobject of non-array type <code>T</code> is specified to
|
||||
be value-initialized, <code>make_shared</code> shall perform this
|
||||
initialization via the expression <code>::new(ptr) T()</code>, where
|
||||
<code>ptr</code> has type <code>void*</code> and points to storage
|
||||
suitable to hold an object of type <code>T</code>.</p>
|
||||
<p>When a subobject of non-array type <code>T</code> is specified to
|
||||
be value-initialized, <code>allocate_shared</code> shall perform
|
||||
this initialization via the expression
|
||||
<code>allocator_traits<A2>::construct(a2, ptr)</code>, where
|
||||
<code>ptr</code> points to storage suitable to hold an object
|
||||
of type <code>T</code> and <code>a2</code> of type A2 is a rebound
|
||||
copy of the allocator <code>allocator</code> passed to
|
||||
<code>allocate_shared</code> such that its <code>value_type</code>
|
||||
is <code>T</code>.</p>
|
||||
<p>When a subobject of non-array type <code>T</code> is specified to
|
||||
be default-initialized, <code>make_shared_noinit</code> and
|
||||
<code>allocate_shared_noinit</code> shall perform this
|
||||
@@ -138,6 +152,9 @@ template<typename U, typename A>
|
||||
the initialized elements should be destroyed in the reverse order
|
||||
of their construction.</p>
|
||||
</blockquote>
|
||||
<p><b>Notes:</b> These functions will typically allocate more memory
|
||||
than <code>sizeof(U)</code> to allow for internal bookkeeping
|
||||
structures such as the reference counts.</p>
|
||||
</blockquote>
|
||||
<h2><a name="functions">Free Functions</a></h2>
|
||||
<pre>template<typename U>
|
||||
@@ -149,8 +166,6 @@ template<typename U, typename A>
|
||||
object of type <code>T[size]</code>.</p>
|
||||
<p><b>Remarks:</b> These overloads shall only participate in overload
|
||||
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p><b>Examples:</b></p>
|
||||
<blockquote>
|
||||
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(size);
|
||||
@@ -166,8 +181,6 @@ template<typename U, typename A>
|
||||
object of type <code>T[N]</code>.</p>
|
||||
<p><b>Remarks:</b> These overloads shall only participate in overload
|
||||
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p><b>Examples:</b></p>
|
||||
<blockquote>
|
||||
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared<int[8]>();
|
||||
@@ -184,8 +197,6 @@ template<typename U, typename A>
|
||||
is initialized to <code>value</code>.</p>
|
||||
<p><b>Remarks:</b> These overloads shall only participate in overload
|
||||
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p><b>Examples:</b></p>
|
||||
<blockquote>
|
||||
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(size, 1);
|
||||
@@ -202,8 +213,6 @@ template<typename U, typename A>
|
||||
initialized to <code>value</code>.</p>
|
||||
<p><b>Remarks:</b> These overloads shall only participate in overload
|
||||
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p><b>Examples:</b></p>
|
||||
<blockquote>
|
||||
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared<int[8]>(1);
|
||||
@@ -219,8 +228,6 @@ template<typename U, typename A>
|
||||
object of type <code>T[size]</code>.</p>
|
||||
<p><b>Remarks:</b> These overloads shall only participate in overload
|
||||
resolution when <code>U</code> is of the form <code>T[]</code>.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p><b>Examples:</b></p>
|
||||
<blockquote>
|
||||
<pre>boost::shared_ptr<int[]> a1 = boost::make_shared_noinit<int[]>(size);
|
||||
@@ -236,8 +243,6 @@ template<typename U, typename A>
|
||||
object of type <code>T[N]</code>.</p>
|
||||
<p><b>Remarks:</b> These overloads shall only participate in overload
|
||||
resolution when <code>U</code> is of the form <code>T[N]</code>.</p>
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<p><b>Examples:</b></p>
|
||||
<blockquote>
|
||||
<pre>boost::shared_ptr<int[8]> a1 = boost::make_shared_noinit<int[8]>();
|
||||
|
||||
Reference in New Issue
Block a user