No, and here's why.
Consider these two cases:
int a, b, c;
auto stackvec = new vector<int*> { &a, &b, &c };
auto heapvec = new vector<int*> { new int, new int, new int };
delete stackvec;
delete heapvec;
If calling delete
on the vector*
s called delete
on the pointers they hold, then you'd be in for a heap of trouble (pun intended) because you'd be delete
ing automatic variables with the first delete
which yields undefined behaviour (a bad thing).
You have to manually iterate the vector
and delete
the pointers yourself when you know they're dynamically allocated, or better, use std::unique_ptr
and you never need to call delete
on anything.
Also, you probably don't need a pointer to a vector
in the first place, but I won't judge you since I don't know your situation.
As for std::array
and std::vector
, you need to know the size of your std::array
at compile time and you can't resize it at runtime, but vector
has neither of those restrictions.