mardi 16 octobre 2018

static constexpr class member variable safe for multithreading reads?

Is it safe to have a static constexpr member variable of a class being read simultaneously by multiple threads? e.g.:

class A{
  public:
    //some code here
  private:
    static constexpr std::size_t x_ = 99;

}

If I create multiple objects of type Class A, each object being used by a different thread, it it safe for each C++11 thread to independently read the member variable x_ without using any locking mechanisms?

Aucun commentaire:

Enregistrer un commentaire