3 ms·
> threading model says that const member methods are thread safe that's only true for standard library objects, although it is an useful guideline for all code
by gpderetta 6y ago
> threading model says that const member methods are thread safe
that's only true for standard library objects, although it is an useful guideline for all code.
- vlovich123 6y agoI don't think that's true. > A C++ standard library function shall not directly or indirectly modify objects (1.10) accessible by threads other than the current thread unless the objects are accessed directly or indirectly via the function’s non-const arguments, including this Consider the case where I invoke `std::find_if`. It takes const iterators to a std::vector. I'm now indirectly modifying objects through standard library functions that are modifying objects by multiple threads through const arguments. Pretty sure this is a viral requirement and using any part of the STL can effectively taint your program if you're not careful.