You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of PointerVector<T> contains a copy constructor/assignment that does a deep copy of all elements.
The issue is that the element wise copy is done via T* x = new T(*elemIt) which would slice off any polymorphic types held in the vector via a pointer to a base type.
A potential twofold solution can be:
Removal of the copy constructor/assignment of PointerVector<T>, making the class similar to a collection of std::unique_ptr.
Adding a SFINAE enabled clone() method, allowing the copy of the vector provided the base class T provides a clone() method.
The text was updated successfully, but these errors were encountered:
The current implementation of
PointerVector<T>
contains a copy constructor/assignment that does a deep copy of all elements.The issue is that the element wise copy is done via
T* x = new T(*elemIt)
which would slice off any polymorphic types held in the vector via a pointer to a base type.A potential twofold solution can be:
PointerVector<T>
, making the class similar to a collection ofstd::unique_ptr
.clone()
method, allowing the copy of the vector provided the base classT
provides aclone()
method.The text was updated successfully, but these errors were encountered: