[Insight-developers] CreateAnother vs. Clone

M Stauffer -V- mstauff at verizon.net
Thu Jun 14 14:55:51 EDT 2012


Hi,

I'm wondering about Object::CreateAnother vs. Object::Clone.
CreateAnother seems to be for creating an instance of a class from an
existing instance, without having to know the exact type, and *without*
copying the state of the existing instance. And Clone is for creating an
instance *with* copying the state.

But poking around a bit, I see the FEM module seems to use CreateAnother
like Clone.Otherwise the only place I see CreateAnother reimplemented is
in itkBSplineDeformableTransform.h, where the comment says maybe Clone
should be used. Is that a mistake, or am I missing something?

e.g.

Modules/Numerics/FEM/include/itkFEMElement2DC0LinearLineStress:49:

  /** CreateAnother method will clone the existing instance of this
type,
   * including its internal member variables. */
  virtual::itk::LightObject::Pointer CreateAnother(void) const;

and the implementation does clone the state.

Thanks,
Michael



More information about the Insight-developers mailing list