
Martin Bonner wrote:
From: Jonathan Wakely
clone_ptr also needs the definitions of all derived classes to be visible, whereas something like ptr_container that uses a clone() member function only needs to see the definition of the base class and can do everything through the base class' interface.
I think it only needs the definition available for the constructor (which is where a class derived from his "copier" class is instantiated). [snip]
This would not be possible with std::vector<clone_ptr<Base> >: [snip bad example] The fill() function can now be implemented in another file and populate the vector with any type derived from Base, without recompiling pc.cc
I think that is supported with clone_ptr. The file implementing fill would need the full definition of the derived type(s) of course, but that is less restrictive.
And to be expected ... yes, you're right. I might have had another example in mind originally but can't think of it now. I remove my objection! jon