W
werasm
Hi all,
Traditionally the prototype pattern (cloning) causes
the "cloned" to be copied. Is there an idiom where
the method performing the creation creates the
default type (without cloning). Small example:
template <class T>
struct clonable
{
virtual T* clone() const; //calls new T( *this );
};
template <class T>
struct xxx_able
{
virtual T* xxx() const; //calls new T();
};
Note that this is similar to factory functions, but not
entirely the same as factory functions are aware of
type.
Therefore - I want a prototype that provides the correct
type without cloning. What is the idiom called?
Regards,
Werner
Traditionally the prototype pattern (cloning) causes
the "cloned" to be copied. Is there an idiom where
the method performing the creation creates the
default type (without cloning). Small example:
template <class T>
struct clonable
{
virtual T* clone() const; //calls new T( *this );
};
template <class T>
struct xxx_able
{
virtual T* xxx() const; //calls new T();
};
Note that this is similar to factory functions, but not
entirely the same as factory functions are aware of
type.
Therefore - I want a prototype that provides the correct
type without cloning. What is the idiom called?
Regards,
Werner