OscMessage Inside An std::vector


I am attempting to create a ‘buffer’ of OscMessages by creating a vector with value type OSCMessage. When trying to send these OSC messages, I get bad access errors/ throw out of range errors from the vector when using operator[] or .at. There is an address and argument in the OSC message, what is the cause of this error?
edit: added photos
Screen Shot

Screen Shot 3


Are you doing things thread-safely?


Which parts of the OSC classes would involve doing things thread safely? I didn’t think separate threads were used in the OSCMessage class?


OK, looks like you just have an error in your for loop that iterates the vector. The condition should not be <= but < instead. (The last valid element index in the vector is size()-1, not size().)


I can’t believe after 2 hours of bug searching that was the problem… Thanks for the quick fix!


Also, since it’s a vector, you could use an Iterator to access it, in which case you wouldn’t have had this error. :slight_smile:


Or C++11 range-based for loop… :wink: