Boost C++ Libraries: Ticket #5664: multi_array's operator() checks for Collection concept but requires RandomAccessCollection https://svn.boost.org/trac10/ticket/5664 <p> Hi, </p> <p> The summary says it all, really. The code that implements operator() looks like this: </p> <pre class="wiki"> template &lt;typename Reference, typename IndexList, typename TPtr&gt; Reference access_element(boost::type&lt;Reference&gt;, const IndexList&amp; indices, TPtr base, const size_type* extents, const index* strides, const index* index_bases) const { ignore_unused_variable_warning(index_bases); ignore_unused_variable_warning(extents); #if !defined(NDEBUG) &amp;&amp; !defined(BOOST_DISABLE_ASSERTS) for (size_type i = 0; i != NumDims; ++i) { BOOST_ASSERT(indices[i] - index_bases[i] &gt;= 0); BOOST_ASSERT(size_type(indices[i] - index_bases[i]) &lt; extents[i]); } #endif index offset = 0; for (size_type n = 0; n != NumDims; ++n) offset += indices[n] * strides[n]; return base[offset]; } </pre><p> It uses operator[] for the indices, but that operator is not a member of the Collection concept, so an iterator should be used instead. </p> <p> I also think that requiring an index type to model the Collection concept was a poor choice. size(), empty() and swap() aren't needed to subscript a multi_array. Also, begin() and end() are required to be member functions, which is hard to do when trying to use a type from a library. I think it would be better to require a <a class="missing wiki">SinglePassRange</a>, as it solves the above problems. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5664 Trac 1.4.3 Ronald Garcia Fri, 13 Jan 2012 16:07:07 GMT <link>https://svn.boost.org/trac10/ticket/5664#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5664#comment:1</guid> <description> <p> Boost.Range did not exist when <a class="missing wiki">MultiArray</a> was written. That being said, I'll look into this further. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ronald Garcia</dc:creator> <pubDate>Wed, 18 Jan 2012 02:29:47 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5664#comment:2 https://svn.boost.org/trac10/ticket/5664#comment:2 <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">fixed</span> </li> </ul> <p> Checked a fix into SVN. </p> Ticket Ronald Garcia Thu, 17 May 2012 14:52:53 GMT <link>https://svn.boost.org/trac10/ticket/5664#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5664#comment:3</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78496" title="Pushing fixes over from the trunk to the release branch. Fixes #5664 ...">[78496]</a>) Pushing fixes over from the trunk to the release branch. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5664" title="#5664: Bugs: multi_array's operator() checks for Collection concept but requires ... (closed: fixed)">#5664</a> Fixes <a class="reopened ticket" href="https://svn.boost.org/trac10/ticket/4874" title="#4874: Bugs: multi_array compile errors using Visual C++ 2010 in debug mode (reopened)">#4874</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>