Re: [Boost-bugs] [Boost C++ Libraries] #1045: [multi_array] Need a proper swap operation

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1045: [multi_array] Need a proper swap operation
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-13 16:22:54


#1045: [multi_array] Need a proper swap operation
---------------------------------------------+------------------------------
  Reporter: Marcus Lindblom <macke@…> | Owner: garcia
      Type: Feature Requests | Status: new
 Milestone: To Be Determined | Component: multi_array
   Version: Boost 1.34.0 | Severity: Optimization
Resolution: | Keywords:
---------------------------------------------+------------------------------

Comment (by Rhys Ulerich <rhys.ulerich@…>):

 Thanks for looking into it Ronald.

 Just reading back over this chain of comments, and I noticed you said
 {{{
 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.
 }}}
 but I don't read
 http://www.boost.org/doc/libs/1_48_0/libs/multi_array/doc/reference.html#MultiArray
 as saying anything at all about {{{operator=}}} within the MultiArray
 concept. No {{{operator=}}} specification. No Assignable requirement.

 You also said
 {{{
 Then multi_array and multi_array_ref can
 independently support a more traditional operator=() behavior, which
 would be compatible with your swap.
 }}}
 but I'm not seeing how the proposed swap is incompatible with a naive swap
 built on {{{multi_array::operator=}}} or {{{multi_array_ref::operator=}}}
 in the case where their {{{operator=}}} precondition
 {{{
 std::equal(this->shape(),this->shape()+this->num_dimensions(), x.shape());
 }}}
 holds. The {{{operator=}}} postcondition will hold and {{{operator==}}}
 will report logical equivalence as expected after the swap. The proposed
 swap is a superset as it can handle situations when the precondition
 fails.

 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/1045#comment:10>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:08 UTC