lundi 17 juillet 2017

Thread safety of the non-write member functions of vectors and lists in C++

If I'm accessing the member functions of the std::vector or std::list, it is threadsafe ?

Example:

struct ABC
{
...
}

std::vector<ABC> vecofAbc;

Are the following operations threadsafe as they are just read ?

vecofAbc.at(1) ;
ABC::iterator iter = vecofAbc.end();
ABC::iterator iter = vecofAbc.begin();

Similiarly are the above member function for std::list thread safe ?

I know push_back() would not be a threadsafe as it's write.

Aucun commentaire:

Enregistrer un commentaire