should help you out It's fine to use either an array or vector to hold pointers to polymorphic types. The problem is if you try to treat an array of objects polymorphically. Array access via a pointer uses the pointer type to determine the size of the array objects, which will go horribly wrong if the pointer type does not match the object type.
Base * stuff = new Derived; // No compile error: pointer conversion is allowed
stuff.do_something(); // Still no compile error, but weird runtime errors.
To fix the issue you can do copy_if is primarily for copying a range to another range/container I.e. by design, the nature of the algorithm is to copy the elements satisfying some condition to another (non-overlapping) range or to a new container. remove_if is more appropriate for what you need; it is exactly for filtering out as you expect. However, it only removes the elements by overwriting; the remnants between the old and new ends would be unspecified elements after the function's completion and needs to be manually erased using erase, like so: