I'm using the various LLVM set containers (SmallPtrSet and the like), and something I need to do fairly often is iterate over a set, removing all elements that don't pass a test. Now, doing this on lists is fairly straightforward using the "it = container.erase(it)" idiom so as to keep the iterator valid during the delete. However, the set classes don't have a means to both iterate and mutate the set at the same time. This means that I tend to use SmallVector in a lot of places where I really want to use a set. In other cases I copy from one set to another as I'm filtering, although I'm concerned about the overhead of copying the set.<div>

<br></div><div>What I'm wondering is what's the best practice for these kinds of operations?<br clear="all"><br>-- <br>-- Talin<br>
</div>