Changeset 3467


Ignore:
Timestamp:
Feb 10, 2016, 9:41:23 AM (6 years ago)
Author:
Peter
Message:

add VectorMutable? assignment operator to the API (using already implemented assign function). Although VectorMutable? is not designed to be inherited from (except for Vector and VectorView?), it should be mention that a virtual pure function was introduced here, which likely will break classes inherited from VectorMutable?. fixes #840

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r3459 r3467  
    44
    55version 0.14 (released NOT YET)
     6  - A new (private) piure virtual function assign(const VectorBase&)
     7    was added in VectorMutable. (ticket #840)
    68  - WeightedIterator is std::input_iterator_tag (ticket #803, r3459)
    79  - Fisher::p_value exact is modified and the summation now runs over
  • trunk/test/vector.cc

    r2919 r3467  
    5353
    5454void test_sort(test::Suite&);
     55void test_vector_mutable_assignment(test::Suite&);
    5556
    5657int main(int argc,char* argv[])
     
    355356  // test that sort can handle NaN properly
    356357  test_sort(suite);
     358  // test for ticket 840
     359  test_vector_mutable_assignment(suite);
    357360
    358361  return suite.return_value();
     
    378381    }
    379382}
     383
     384
     385void test_assign(utility::VectorMutable& lhs, const utility::Vector& rhs)
     386{
     387  lhs = rhs;
     388}
     389
     390
     391void test_assign2(utility::VectorMutable& lhs, const utility::VectorView& rhs)
     392{
     393  lhs = rhs;
     394}
     395
     396
     397void test_assign3(utility::VectorMutable& lhs, const utility::VectorBase& rhs)
     398{
     399  lhs = rhs;
     400}
     401
     402
     403void test_assign4(utility::VectorMutable& lhs, const utility::VectorMutable& rhs)
     404{
     405  lhs = rhs;
     406}
     407
     408
     409void test_vector_mutable_assignment(test::Suite&)
     410{
     411  utility::Vector vec(10, 1);
     412  utility::Vector vec2(10, 2);
     413  utility::VectorView view(vec2);
     414  utility::VectorConstView const_view(vec2);
     415  test_assign(vec2, vec);
     416  test_assign(view, vec);
     417
     418  test_assign2(view, view);
     419  test_assign2(vec, view);
     420
     421  test_assign3(view, view);
     422  test_assign3(vec, view);
     423  test_assign3(vec2, vec);
     424  test_assign3(view, vec);
     425  test_assign3(vec, const_view);
     426
     427  test_assign4(view, view);
     428  test_assign4(vec, view);
     429  test_assign4(vec2, vec);
     430  test_assign4(view, vec);
     431}
  • trunk/yat/utility/VectorMutable.cc

    r2992 r3467  
    171171
    172172
     173  const VectorMutable& VectorMutable::operator=(const VectorBase& rhs)
     174  {
     175    return assign(rhs);
     176  }
     177
     178
     179  const VectorMutable& VectorMutable::operator=(const VectorMutable& rhs)
     180  {
     181    return assign(rhs);
     182  }
     183
     184
    173185  void shuffle(VectorMutable& invec)
    174186  {
  • trunk/yat/utility/VectorMutable.h

    r2992 r3467  
    209209    const VectorMutable& operator*=(double d);
    210210
     211    /**
     212       \brief assignment
     213
     214       \since New in yat 0.14
     215     */
     216    const VectorMutable& operator=(const VectorMutable&);
     217
     218    /**
     219       \brief assignment
     220
     221       \since New in yat 0.14
     222     */
     223    const VectorMutable& operator=(const VectorBase&);
     224
    211225  protected:
    212226    /**
     
    219233
    220234  private:
    221     // copy assignment not allowed
    222     const VectorMutable& operator=(const VectorMutable&);
    223 
     235    virtual const VectorMutable& assign(const VectorBase& rhs)=0;
    224236  };
    225237
Note: See TracChangeset for help on using the changeset viewer.