Boost C++ Libraries: Ticket #4637: An extra scoped_array(n) constructor, please! https://svn.boost.org/trac10/ticket/4637 <p> When I construct a non-empty <em>scoped_array&lt;my_type&gt;</em>, I currently need to specify the type <em>my_type</em> twice: </p> <pre class="wiki"> boost::scoped_array&lt;my_type&gt; a( new my_type[n]() ); </pre><p> Please consider supporting the following as an equivalent: </p> <pre class="wiki"> boost::scoped_array&lt;my_type&gt; a(n); </pre><p> A patch to the trunk (scoped_array.hpp + smart_ptr_test.cpp) is hereby attached. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4637 Trac 1.4.3 niels_dekker Wed, 08 Sep 2010 09:37:58 GMT attachment set https://svn.boost.org/trac10/ticket/4637 https://svn.boost.org/trac10/ticket/4637 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">extra_scoped_array_constructor.patch</span> </li> </ul> Ticket olafvdspek@… Thu, 03 Nov 2011 12:19:58 GMT <link>https://svn.boost.org/trac10/ticket/4637#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4637#comment:1</guid> <description> <p> Hoi Niels, </p> <p> You used "new T[]()" instead of "new T[]". Do you require the former or would the latter be fine for you? Not everyone needs the elements to be initialized. Initializing them after construction is possible, uninitializing them isn't. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>niels_dekker</dc:creator> <pubDate>Thu, 03 Nov 2011 14:22:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4637#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4637#comment:2</guid> <description> <p> Hoi Olaf, </p> <p> Thanks for your feedback. I prefer to have the elements value-initialized by such a scoped_array(n) constructor. That's also consistent with the interface of std::vector: </p> <pre class="wiki"> // All 'n' elements value-initialized: boost::scoped_array&lt;my_type&gt; a(n); std::vector&lt;my_type&gt; v(n); </pre><p> People who really need to have uninitialized elements can still use the old (verbose) syntax, of course... </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Thu, 03 Nov 2011 15:06:36 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4637#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4637#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4637#comment:2" title="Comment 2">niels_dekker</a>: </p> <blockquote class="citation"> <p> Hoi Olaf, </p> <p> Thanks for your feedback. I prefer to have the elements value-initialized by such a scoped_array(n) constructor. </p> </blockquote> <p> The difference only applies to types without constructors (AFAIK). </p> <blockquote class="citation"> <p> That's also consistent with the interface of std::vector: </p> <pre class="wiki"> // All 'n' elements value-initialized: boost::scoped_array&lt;my_type&gt; a(n); std::vector&lt;my_type&gt; v(n); </pre><p> People who really need to have uninitialized elements can still use the old (verbose) syntax, of course... </p> </blockquote> <p> That argument applies to not initializing as well. I can't remember ever using new T[]() actually. What use cases do you have for it? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>niels_dekker</dc:creator> <pubDate>Sat, 05 Nov 2011 13:12:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4637#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4637#comment:4</guid> <description> <p> For the record, this subject is being discussed at [boost] [smart_ptr] <a class="ext-link" href="http://comments.gmane.org/gmane.comp.lib.boost.devel/224931"><span class="icon">​</span>scoped_array / shared_array (size_t) constructor</a>, starting at <a class="ext-link" href="http://lists.boost.org/Archives/boost/2011/10/187198.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2011/10/187198.php</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>