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?]