C++ Vector, set_difference not changing .size() and other issues
I am having some odd problems while working with vectors. After applying set_difference to a vector and then cycling through the result vector, I see that the size() of the old vector has not changed. Furthermore, I am seeing crashes if the first vector is beyond a certain size. The code below is self contained (for my coding environment).
There is some other processes included that may or may not be relevant, I'm not sure. There is two alternative inputs for vct_diff, the first shows the error in size() and the second causes a crash. Comment out one or the other to see how they both work. Code:
#include <cstdlib> |
Quote:
|
Quote:
But it seems really counter-intuitive. You get an iterator back and it appears you do get something added to the vector where you wanted it. What am I missing? Is there some other way of restoring .size() for the vector, or is it that the vector doesn't really exist with added data? Why would you point the result to some place on a vector if you didn't want it added there? I don't get it. |
Here is the example from cplusplus.com it has a few clues,
http://www.cplusplus.com/reference/a...et_difference/ Code:
// set_difference example I have yet to really get used to the meaning of the iterator. This, "vct.end()" is not a vector, it is an iterator. |
Quote:
Quote:
|
All times are GMT -5. The time now is 06:06 AM. |