Add additional overload for allocate_shared and make_shared array forms that take initializer list of T for the array types T[M][N]

[SVN r81341]
This commit is contained in:
Glen Fernandes
2012-11-14 15:18:50 +00:00
parent 3b0b10d06d
commit 6b2556edfb
6 changed files with 98 additions and 7 deletions

View File

@@ -56,7 +56,10 @@
template<typename T, typename... Args>
shared_ptr&lt;T[][N]&gt; <a href="#functions">make_shared</a>(size_t size, initializer_list&lt;T&gt; list);
template&lt;typename T, typename... Args&gt;
shared_ptr&lt;T[M][N]&gt; <a href="#functions">make_shared</a>(initializer_list&lt;T&gt; list);
template&lt;typename T, typename A, typename... Args&gt;
shared_ptr&lt;T[]&gt; <a href="#functions">allocate_shared</a>(const A&amp; allocator, initializer_list&lt;T&gt; list);
@@ -65,6 +68,9 @@
template&lt;typename T, typename A, typename... Args&gt;
shared_ptr&lt;T[][N]&gt; <a href="#functions">allocate_shared</a>(const A&amp; allocator, size_t size, initializer_list&lt;T&gt; list);
template&lt;typename T, typename A, typename... Args&gt;
shared_ptr&lt;T[M][N]&gt; <a href="#functions">allocate_shared</a>(const A&amp; allocator, initializer_list&lt;T&gt; list);
#endif
template&lt;typename T&gt;
@@ -117,7 +123,15 @@ template&lt;typename T, typename A, typename... Args&gt;
constructor of <code>T</code> for each array element.</p>
</blockquote>
<h2><a name="example">Example</a></h2>
<pre>boost::shared_ptr&lt;int[]&gt; array = boost::make_shared&lt;int[]&gt;(size);</pre>
<pre>boost::shared_ptr&lt;int[]&gt; a1 = boost::make_shared&lt;int[]&gt;(size);
boost::shared_ptr&lt;point[5]&gt; a2 = boost::make_shared&lt;point[5]&gt;(x, y);
boost::shared_ptr&lt;int[5]&gt; a3 = boost::make_shared&lt;int[5]&gt;();
boost::shared_ptr&lt;int[]&gt; a4 = boost::make_shared&lt;int[]&gt;({1, 2, 3});
boost::shared_ptr&lt;int[3]&gt; a5 = boost::make_shared&lt;int[3]&gt;({1, 2, 3});
boost::shared_ptr&lt;int[][3]&gt; a6 = boost::make_shared&lt;int[][3]&gt;(size, {1, 2, 3});
boost::shared_ptr&lt;int[5][3]&gt; a7 = boost::make_shared&lt;int[5][3]&gt;({1, 2, 3});
boost::shared_ptr&lt;int[]&gt; a8 = boost::make_shared_noinit&lt;int[]&gt;(size);
boost::shared_ptr&lt;int[5]&gt; a9 = boost::make_shared_noinit&lt;int[5]&gt;();</pre>
<hr>
<p>$Date: 2012-10-30 10:12:25 -0800 (Tue, 30 Oct 2012) $</p>
<p><small>Copyright 2012 Glen Fernandes. Distributed under the Boost