i have a vector to which i want to add elements at random places. (I only say random because the act of insertion is not serial or sequential , rather it is formulaic.)
I have a vector defined like so:
When I add i want to say something like this:
However, if i have an empty i to begin with, so the iterator begin is a bad pointer.
How can i store the correct begin position for an empty vector?
i guess i could check to see if the vector was empty, add the first element, get begin to point to the first element etc. But i think this approach is inelegant. Can I somehow do things in the approach mentioned above?