Boost C++ Libraries: Ticket #6793: Support construction from range https://svn.boost.org/trac10/ticket/6793 <p> Could you support construction from a range and from an iterator pair? I don't know what to do when the input doesn't match the array size. If it's smaller you could default construct the rest of the array. If it's larger, you could truncate, std::terminate() or throw. Or just consider it undefined behaviour. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6793 Trac 1.4.3 Olaf van der Spek <olafvdspek@…> Mon, 16 Apr 2012 16:36:35 GMT <link>https://svn.boost.org/trac10/ticket/6793#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6793#comment:1</guid> <description> <p> Just read that constructors are not an option. How about make_array() instead? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Mon, 17 Dec 2012 17:21:00 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/6793#comment:2 https://svn.boost.org/trac10/ticket/6793#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> It seems to me that <code>make_array</code> would require either (a) returning the array by value (copying or depending on RVO), or passing in the destination array by reference (which means you have to construct it beforehand. </p> <p> In either case, I don't see a compelling need, when compared to: </p> <pre class="wiki">boost::array&lt;T, N&gt; arr; std::copy ( iter1, iter2, arr.begin ()); </pre><p> Can you show me an example where <code>make_array</code> would be a significant improvement? Thanks! </p> Ticket Olaf van der Spek <olafvdspek@…> Mon, 17 Dec 2012 17:31:46 GMT <link>https://svn.boost.org/trac10/ticket/6793#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6793#comment:3</guid> <description> <p> That requires temp vars for both input and output. </p> <pre class="wiki">string g() { return "Olaf"; } void f(array&lt;char, 20&gt; const&amp;); f(make_array(g())); // desired { string s = g(); array&lt;char, 20&gt; a; std::copy(s.begin(), s.end(), a.begin()); f(a); } </pre><p> IMO the one liner looks much better than the 6 liner and the 6 liner can't even do size checking. </p> </description> <category>Ticket</category> </item> </channel> </rss>