clone method of Object

Qian Xu quian.xu at stud.tu-ilmenau.de
Wed Apr 15 07:25:23 PDT 2009


grauzone wrote:
> newobject.tupleof[i] = old.tupleof[i];

If the current value of tupleof[i] is an object, the object will be
referenced, won't it?

Shall I write:

  auto elem = old.tupleof[i];
  static if (is(typeof(elem) == class))
  {
     newobject.tupleof[i] = clone(elem);
  }
  else
  {
     newobject.tupleof[i] = elem;
  }




--Qian


More information about the Digitalmars-d-learn mailing list