c++ - empty a specific element of a vector -



c++ - empty a specific element of a vector -

i want set element @ specific position of vector null, can following:

vector<ixmldomnodeptr> vec1;// filled somehow vec1[i] = nullptr;// specific position

ps. want maintain entry nulled, acts place holder, think maybe vec[i] = 0 do?

may erase() help, e.g.

vec1.erase(vec1.begin() + i);

when iterate through next, entry not there...

now know want do, ought work..

vector<boost::optional<ixmldomnodeptr> > vec1; // populate // erase vec1[i] = boost::none; // null.

this without knowing ixmldomnodeptr (if name implies pointer), setting 0 ought work.

vec1[i] = 0;

note: if dynamically allocated object, setting 0 not clear memory setting null in java - in c++ have explicitly clean first, i.e.

delete vec1[i]; vec1[i] = 0;

c++ stdvector

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -