Changeset 1197


Ignore:
Timestamp:
Aug 13, 2003, 5:20:30 PM (17 years ago)
Author:
sveta
Message:
  • Method "=" is changed (problems with destructor).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/runtime/rf_vector.ih

    r1120 r1197  
    1111{
    1212
    13 /*inline Vector::Vector(Vector const& _vector)
    14 {
    15   new(this) Vector(_vector.length); 
    16   for (size_t i = 0; i < _vector.length; i++)
    17     self[i] = _vector[i];
    18 }*/
    19 
    2013inline Vector::Vector (size_t _length /* = 0 */) :
    2114  Object (),
    2215  pxx::Vector<Expr> (_length)
    23 {}
     16{ }
    2417
    2518inline Vector::Vector (size_t _length, Expr const& _fill) :
     
    4639      if (!v)
    4740        FATAL ("Invalid argument");
     41      for (size_t i = 0; i < v->get_length(); i++)
     42        self[index++] = (*v)[i];
    4843    }
    4944  }
     
    8883inline const Vector& Vector::operator= (Vector const& _vector)
    8984{
     85  size_t len = get_length();
     86  size_t vlen = _vector.get_length();
    9087  if (this != &_vector) {
    91     this->~Vector();
    92     new (this) Vector(_vector.get_length());
    93     for (size_t i = 0; i < _vector.get_length(); i++)
     88    if (len > vlen)
     89      this -> decrease(len-vlen);
     90    else
     91      if (len < vlen)
     92        this -> expand(vlen-len);
     93//    this->~Vector();
     94//    new (this) Vector(_vector.get_length());
     95    for (size_t i = 0; i < vlen; i++)
    9496      self[i] = _vector[i];
    9597  }
Note: See TracChangeset for help on using the changeset viewer.