set returns const_iterators (the standard says set<T>::iterator is const, and that set<T>::const_iterator and set<T>::iterator may in fact be the same type – see 23.2.4/6 in n3000.pdf) because it is an ordered container. If it returned a regular iterator, you’d be allowed to change the items value out from under the container, potentially altering the ordering.
Your solution is the idiomatic way to alter items in a set.