"lazy erase with vector"
is it possible to auto erase a pointer from a vector container?
a stuff what's like swap...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include<vector>
int main(){
std::vector<int*>ptrs;
int*ptr=new int[20];
ptrs.push_back(ptr);
//size() = 1
autoremove(ptr,ptrs);//that thing
delete[]ptr;
//size() = 0
return 0;
};
|
Huh? What does it mean to "auto erase"?
There is no way for the vector to know that pointers it holds have had their pointed-to memory deallocated, if that is what you are asking.
Topic archived. No new replies allowed.