Message is a class I made. I have a set of them in the main function that I pass to messageTimeOut (and some other functions). In messageTimeOut using an itorator I am loopi
Objects in a set are const meaning that they are not mutable. Here are some options
1) Create copies of the messages in a new set
2) Remove the messages, mutate them, and put them back.
3) Remove the "timeout" field from the message.
Of these I prefer number 3. The fact that you are trying to mutate the messages is a "bad code smell". If you were to avoid all changing of data and instead create a new structure (for example a std::map) then you could reduce the amount of thread synchronization.