Boost C++ Libraries: Ticket #7405: Coercion to multi_array_ref from array_view https://svn.boost.org/trac10/ticket/7405 <p> I'd like to have functions that can be passed references to arrays of a given storage type and rank. Take a look at the following code: </p> <p> template &lt;class A&gt; void foo_duck(A ma) { </p> <blockquote> <p> ma<a class="missing changeset" title="No changeset 0 in the repository">[0]</a><a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> = 1.0; </p> </blockquote> <p> } </p> <p> typedef boost::multi_array_ref&lt;double, 2&gt; ref_array_2d; void foo_ref(ref_array_2d ma) { </p> <blockquote> <p> ma<a class="missing changeset" title="No changeset 0 in the repository">[0]</a><a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> = 1.0; </p> </blockquote> <p> } </p> <p> int main() { </p> <blockquote> <p> typedef boost::multi_array&lt;double, 3&gt; array_3d; typedef boost::multi_array_types::index_range range; </p> </blockquote> <blockquote> <p> array_3d A(boost::extents<a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">[3]</a><a class="changeset" href="https://svn.boost.org/trac10/changeset/4" title="Tweak disclaimer formatting, again">[4]</a><a class="changeset" href="https://svn.boost.org/trac10/changeset/4" title="Tweak disclaimer formatting, again">[4]</a>); array_3d::array_view&lt;2&gt;::type slice = A[boost::indices[1][range()][range()]]; </p> </blockquote> <blockquote> <p> foo_duck(slice); foo_ref(slice); </p> </blockquote> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> <p> foo_duck works fine, but foo_ref does not; I get a compiler error (gcc 4.6.3, boost 1.47) like so: "error: could not convert ‘slice’ from ‘boost::multi_array&lt;double, 3ul&gt;::array_view&lt;2ul&gt;::type {aka boost::detail::multi_array::multi_array_view&lt;double, 2ul&gt;}’ to ‘ref_array_2d {aka boost::multi_array_ref&lt;double, 2ul&gt;}’" </p> <p> I suspect, without having looked at the code itself, that multi_array_ref was never designed to be coerced from array_view, but I don't understand why. Is there a solution to my foo_ref problem that doesn't involve moving all such functions to headers and templating them? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7405 Trac 1.4.3