I saw that there has been a TON of messages regarding this on here recently and I hope that this isn't going to hit the cap on the "Sieve of E." (I can't spell that guys name... :/ )
It's hard to relate the code you supply with the subject of the thread since you definitely do not seem to be implementing a sieve. Is it your intent for v to represent the sieve? If it is, what do you think you're accomplishing by erasing elements?
I would worry more about getting the sieve right than I would about how to fill a set with the sieve results.
[edit: And why don't you move this out of the unix/linux forum to one where it's on topic?]