Boost C++ Libraries: Ticket #6626: shallow_array_adaptor bug in swap function https://svn.boost.org/trac10/ticket/6626 <p> <em>boost::numeric::ublas::vector&lt; T,shallow_array_adaptor&lt;T&gt; &gt;</em> fails when it is assigned with an expression. For example: </p> <pre class="wiki">#define BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR #include &lt;boost/numeric/ublas/vector.hpp&gt; struct point { double x; double y; double z; }; void test() { using namespace boost::numeric::ublas; point p = { 1, 2, 3 } shallow_array_adaptor&lt;double&gt; a(3, &amp;p.x); // Ok, a holds p address vector&lt;double, shallow_array_adaptor&lt;double&gt; &gt; v(a); // Ok, v holds p address v += v; // Ok, now p = { 2, 4, 6 } v /= 2; // Ok, now p = { 1, 2, 3 } v = v*2; // &lt;- Oh no, p = { 1, 2, 3 } !!! } </pre><p> <em>vector</em> creates a temporary object and it calls to <em>shallow_array_adaptor::swap</em>. This function doesn't check if it is the owner of pointers to swap. When both are data owners can do that (as unbounded_array does). But if they are not then they should swap as bounded_array does. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6626 Trac 1.4.3 Guillermo Ruiz Troyano <ruiztroyano@…> Tue, 28 Feb 2012 16:51:11 GMT attachment set https://svn.boost.org/trac10/ticket/6626 https://svn.boost.org/trac10/ticket/6626 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">patchfile.patch</span> </li> </ul> <p> Patch of boost::numeric::ublas::shallow_array_adaptor::swap </p> Ticket