15 Apr
2012
15 Apr
'12
7:03 p.m.
Thank you very much sir , but how could possibly those threads modify the itemes in a vector using [] operator!! ? in my sample i just had them read a value using [] operator ! there is no assignment !
You call a non-const overload of operator[], so theoretically it can change the vector (if it's not prohibited by the standard). Actually, even if it were the const overload, it could change some mutable internal object state (again, it's worth reading what the standard says about it), so I guess you can't treat the operator[] as a pure "reader". Anyway, in your case it's not so important, as you use the regular mutex, not shared_mutex.