Boost C++ Libraries: Ticket #1045: [multi_array] Need a proper swap operation https://svn.boost.org/trac10/ticket/1045 <p> See <a class="ext-link" href="http://lists.boost.org/Archives/boost/2007/05/121165.php"><span class="icon">​</span>this email</a> which was unanswered. </p> <p> Basically, a proper pointer swap operation would be both efficent and useful. </p> <p> (P.S. multi_array is not listed in components?) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1045 Trac 1.4.3 Ronald Garcia Wed, 04 Jul 2007 10:43:12 GMT owner set https://svn.boost.org/trac10/ticket/1045#comment:1 https://svn.boost.org/trac10/ticket/1045#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Ronald Garcia</span> </li> </ul> Ticket Marshall Clow Sun, 19 Aug 2007 15:23:19 GMT component changed https://svn.boost.org/trac10/ticket/1045#comment:2 https://svn.boost.org/trac10/ticket/1045#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">multi_array</span> </li> </ul> Ticket Chris Kieschnick <wildjokerman@…> Thu, 14 May 2009 21:05:25 GMT <link>https://svn.boost.org/trac10/ticket/1045#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1045#comment:3</guid> <description> <p> I too would benefit from this feature as I have a large boost::multi_array (elements number in the millions or hundreds of thousands) in a thread which I am handing off to another thread before the initial thread dies. (This thread is merely an algorithm and it must post its result to a queue which maintains result output in the same order that each algorithm thread was started). I don't think it should be necessary that I use boost::shared_ptrs for a structure with such a small local footprint (some pointers and other information I presume). For now I do a copy until I can get around to refactoring to add a shared_ptr. </p> </description> <category>Ticket</category> </item> <item> <author>Rhys Ulerich <rhys.ulerich@…></author> <pubDate>Sun, 29 Nov 2009 23:46:53 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/1045#comment:4 https://svn.boost.org/trac10/ticket/1045#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">rhys.ulerich@…</span> added </li> </ul> <p> Me too on the feature request. I've got some low-storage numeric algorithms that sit atop multi_array and multi_array_ref. Being able to swap two multi_arrays or two multi_array_refs would be very, very helpful. </p> Ticket Rhys Ulerich <rhys.ulerich@…> Mon, 30 Nov 2009 23:56:29 GMT attachment set https://svn.boost.org/trac10/ticket/1045 https://svn.boost.org/trac10/ticket/1045 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">multi_array_swap.patch</span> </li> </ul> <p> Patch implementing the requested functionality </p> Ticket Rhys Ulerich <rhys.ulerich@…> Tue, 01 Dec 2009 00:00:50 GMT <link>https://svn.boost.org/trac10/ticket/1045#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1045#comment:5</guid> <description> <p> Attached is a patch against 1.41 providing multi_array_ref::swap and multi_array::swap, overloads for boost::swap, some unit tests and a couple of very minor documentation updates. Tests pass against gcc 4.2.4. </p> <p> Sorry for not working from trunk; the resize tests were broken there. The patch rewrites a small portion of resize in terms of the new multi_array::swap operation and I wanted the resize test cases to run against that change. </p> </description> <category>Ticket</category> </item> <item> <author>Rhys Ulerich <rhys.ulerich@…></author> <pubDate>Tue, 01 Dec 2009 03:41:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1045#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1045#comment:6</guid> <description> <p> For whomever reviews this, some details about the patch that I'm not sure I got correct: </p> <ul><li>Handling of non-default allocators <ul><li>In particular, swapping between instances using different allocators </li></ul></li><li>No throw semantics? </li></ul> </description> <category>Ticket</category> </item> <item> <author>rhys.ulerich@…</author> <pubDate>Thu, 02 Dec 2010 18:24:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1045#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1045#comment:7</guid> <description> <p> Just capturing some old email to/from Ronald Garcia regarding the patch... </p> <pre class="wiki">Sat, Dec 12, 2009 at 1:01 PM From: Ronald Garcia &lt;garcia@osl.iu.edu&gt; To: Rhys Ulerich &lt;rhys.ulerich@gmail.com&gt; Hi Rhys, I have looked over your patch to multi_array. The good news is that on the whole I like what you are proposing. The bad news is that I will want to make some more fundamental changes to MultiArray before or at the same time as I add this functionality to the library. The problem right now is that swap as you propose it is not simply a faster-but-equivalent version of the inefficient operator=() based implementation of swap. However I see that more as a problem with operator=() as it's currently presented than a problem with your swap. The current implementation of multi_array and the MultiArray concept use operator=() to represent deep copy semantics, and I now see that as problematic because of the ways that C++ treats operator=() and constructors specially. Before I add swap to multi_array and multi_array_ref, I need to rename the functionality currently associated with operator=() and remove operator= from the concept. Then multi_array and multi_array_ref can independently support a more traditional operator=() behavior, which would be compatible with your swap. I appreciate your contribution to multi_array, and will see about getting other changes going, but it won't happen before the next release is frozen I'm afraid. Best, Ron </pre><pre class="wiki">Sat, Dec 12, 2009 at 1:09 PM From: Rhys Ulerich &lt;rhys.ulerich@gmail.com&gt; To: Ronald Garcia &lt;garcia@osl.iu.edu&gt; Hi Ron, Thanks for looking over the patch, and no problem on holding off on the functionality. My $0.02 is that the deep copy semantics associated with operator= seem reasonable/natural to me in the current implementation, but I may be missing some nuances in the language. I'd be interested in seeing the upcoming changes as they develop. Do you use the boost development list for MultiArray discussion? Or some other list where I can subscribe? - Rhys </pre><pre class="wiki">Sun, Dec 13, 2009 at 8:08 AM From: Ronald Garcia &lt;garcia@osl.iu.edu&gt; To: Rhys Ulerich &lt;rhys.ulerich@gmail.com&gt; Hi Rhys, Thanks for your feedback. There hasn't been a great deal of multi_array discussion in some time, but I will write to the boost developers list about these issues. Cheers, Ron </pre> </description> <category>Ticket</category> </item> <item> <author>Maxim Yanchenko <Maxim.Yanchenko@…></author> <pubDate>Wed, 19 Oct 2011 07:05:03 GMT</pubDate> <title>cc changed https://svn.boost.org/trac10/ticket/1045#comment:8 https://svn.boost.org/trac10/ticket/1045#comment:8 <ul> <li><strong>cc</strong> <span class="trac-author">Maxim.Yanchenko@…</span> added </li> </ul> <p> Hi Ronald, </p> <p> Is there any chance to have this patch properly applied? I understand your desire to refine the concepts and then introduce swap, if you apply the patch now the users would greatly benefit from this already now (after 2 years since the patch was proposed, actually, and 4 years since it was asked) and stop using ugly pseudo-solutions like shared_ptr&lt;multi_array&gt;. Then, when you refine the concepts, nothing will change in the existing production code (wrt swap) which is obviously good. </p> <p> Please consider applying the patch even without your refinement of the operator=(). </p> <p> Thanks, Maxim </p> Ticket Ronald Garcia Fri, 13 Jan 2012 15:34:20 GMT <link>https://svn.boost.org/trac10/ticket/1045#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1045#comment:9</guid> <description> <p> I am revisiting this issue and the broader issue of operator=() as I have time. </p> </description> <category>Ticket</category> </item> <item> <author>Rhys Ulerich <rhys.ulerich@…></author> <pubDate>Fri, 13 Jan 2012 16:22:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1045#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1045#comment:10</guid> <description> <p> Thanks for looking into it Ronald. </p> <p> Just reading back over this chain of comments, and I noticed you said </p> <pre class="wiki">Before I add swap to multi_array and multi_array_ref, I need to rename the functionality currently associated with operator=() and remove operator= from the concept. </pre><p> but I don't read <a href="http://www.boost.org/doc/libs/1_48_0/libs/multi_array/doc/reference.html#MultiArray">http://www.boost.org/doc/libs/1_48_0/libs/multi_array/doc/reference.html#MultiArray</a> as saying anything at all about <code>operator=</code> within the <a class="missing wiki">MultiArray</a> concept. No <code>operator=</code> specification. No Assignable requirement. </p> <p> You also said </p> <pre class="wiki">Then multi_array and multi_array_ref can independently support a more traditional operator=() behavior, which would be compatible with your swap. </pre><p> but I'm not seeing how the proposed swap is incompatible with a naive swap built on <code>multi_array::operator=</code> or <code>multi_array_ref::operator=</code> in the case where their <code>operator=</code> precondition </p> <pre class="wiki">std::equal(this-&gt;shape(),this-&gt;shape()+this-&gt;num_dimensions(), x.shape()); </pre><p> holds. The <code>operator=</code> postcondition will hold and <code>operator==</code> will report logical equivalence as expected after the swap. The proposed swap is a superset as it can handle situations when the precondition fails. </p> <p> Maybe the only incompatibility I could see is whether or not the stride information in a given multi_array is preserved after a swap (naive swap: yes, proposed swap patch: no). But I do not expect (and generally would not want!) a swap that preserved stride information as it would always require a deep copy and defeat the purpose of a lightweight swap. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 03 Aug 2013 21:02:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1045#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1045#comment:11</guid> <description> <p> Now that we have move semantics, is it possible that we can solve the swap problem, w/out touching - at least, for now - the copy constructor? Thank you </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 29 Mar 2018 13:33:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1045#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1045#comment:12</guid> <description> <p> Hi, </p> <p> Is there any progress on this issue? As far as I can see multi_array still doesn't have a move constructor. </p> <p> Thanks! </p> </description> <category>Ticket</category> </item> </channel> </rss>