In general, operations on the standard containers are not thread safe (mostly). The size
call on a std::vector
, for example, may fail when reallocations are happening.
Since a dequeue
does not reallocate or move the elements like a standard vector does, are there still conditions when calling size
on a dequeue can be unsafe? The most likely scenario seems to be when adding/removing elements in a different thread as the size
call is being made, but since accessing an integer is mostly safe, I'm having trouble thinking of how calling size
from a separate thread would be problematic.