I\'ve a question about the thread safety of std::set.
As far as I know I can iterate over a set and add/erase members and that doesn\'t invalidate the iterators.
None of the STL containers is thread safe, so std::set in particular isn’t.
In your case, the issue isn’t even really thread safety, though: You simply share an object across multiple threads (fine) and modify it in one thread (fine as well). But as you’ve already said, modifying the container invalidates its iterators. Whether this happens in the same thread or in a different thread is of no consequence since it’s still the same container.
D'oh! §23.1.2.8 states that inserting doesn’t invalidate iterators.