Boost C++ Libraries: Ticket #4280: Cannot get array type from boost::array https://svn.boost.org/trac10/ticket/4280 <p> There is no function to get array from the boost::array. c_array returns pointer, and operator[] returns reference. </p> <p> There must be additional function, as_array. </p> <p> array&lt;T, N&gt; { </p> <blockquote> <p> typedef T array_type[N]; </p> </blockquote> <blockquote> <p> array_type&amp; as_array() { return elems; } array_type const&amp; as_array() const { return elems; } </p> </blockquote> <p> } </p> <p> It is needed to allow optimizations when function has special overload for arrays. Like std::copy in VC compiler: </p> <ol><li>copy(Input first, Input last, Output dest) </li><li>copy(Input first, Input last, <a class="missing wiki">OutElem</a> (&amp;dest)[size]) </li></ol> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4280 Trac 1.4.3 anonymous Wed, 02 Jun 2010 08:53:57 GMT <link>https://svn.boost.org/trac10/ticket/4280#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4280#comment:1</guid> <description> <p> Sorry for missing code formatting. </p> <div class="wiki-code"><div class="code"><pre> <span class="n">array</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span> <span class="n">N</span><span class="o">&gt;</span> <span class="p">{</span> <span class="k">typedef</span> <span class="n">T</span> <span class="n">array_type</span><span class="p">[</span><span class="n">N</span><span class="p">];</span> <span class="n">array_type</span><span class="o">&amp;</span> <span class="n">as_array</span><span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="n">elems</span><span class="p">;</span> <span class="p">}</span> <span class="n">array_type</span> <span class="k">const</span><span class="o">&amp;</span> <span class="n">as_array</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">elems</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> </pre></div></div> </description> <category>Ticket</category> </item> <item> <dc:creator>NN</dc:creator> <pubDate>Wed, 02 Jun 2010 13:59:57 GMT</pubDate> <title>type changed https://svn.boost.org/trac10/ticket/4280#comment:2 https://svn.boost.org/trac10/ticket/4280#comment:2 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> </ul> <p> There is a solution to use elems public member. It is nicer to have a method for this. </p> Ticket Marshall Clow Wed, 02 Jun 2010 14:22:27 GMT owner changed https://svn.boost.org/trac10/ticket/4280#comment:3 https://svn.boost.org/trac10/ticket/4280#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">No-Maintainer</span> to <span class="trac-author">Marshall Clow</span> </li> </ul> <p> How does this differ from ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2857" title="#2857: Patches: change return type of the c_array() member function (closed: fixed)">#2857</a> ? </p> Ticket Marshall Clow Fri, 13 Aug 2010 20:46:53 GMT <link>https://svn.boost.org/trac10/ticket/4280#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4280#comment:4</guid> <description> <p> Closing as a duplicate of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2857" title="#2857: Patches: change return type of the c_array() member function (closed: fixed)">#2857</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Fri, 13 Aug 2010 20:51:32 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4280#comment:5 https://svn.boost.org/trac10/ticket/4280#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">duplicate</span> </li> </ul> Ticket