Z
zl2k
hi, all
I have some questions about stl vector.
Suppose I have
std::vector<std::vector<int> > v;
//populate v
//now I want to clear v, should I just write:
v.clear();
//or
for (int i = 0; i < v.size(); i++)
v.clear();
v.clear();
What if I have a vector of objects, say
std::vector<boost::shared_ptr<obj> > v;
//populate v
//now I want to clear v, I guess I have to do
for (int i = 0; i < v.size(); i++)
v.reset();
v.clear();
//or maybe I can just do v.clear() since the boost::shared_ptr are
smart pointers and will destroy by itself after v.clear() is excuted?
Thanks for help.
zl2k
I have some questions about stl vector.
Suppose I have
std::vector<std::vector<int> > v;
//populate v
//now I want to clear v, should I just write:
v.clear();
//or
for (int i = 0; i < v.size(); i++)
v.clear();
v.clear();
What if I have a vector of objects, say
std::vector<boost::shared_ptr<obj> > v;
//populate v
//now I want to clear v, I guess I have to do
for (int i = 0; i < v.size(); i++)
v.reset();
v.clear();
//or maybe I can just do v.clear() since the boost::shared_ptr are
smart pointers and will destroy by itself after v.clear() is excuted?
Thanks for help.
zl2k