is multiple assignments of atomic variables, an atomic operation?

Viewed 2082

consider I have two atomic booleans as follows.

private:
    std::atomic_bool x;
    std::atomic_bool y;

Can I say the following operation is atomic? or do I have to use lock_guard to to make sure they are assigned together?

x = y = true; // are two bools assigned together atomically?

also consider in another thread I want to read these booleans.

if(!x && !y) ...

my assumption is that this is not atomic, maybe its better to use atomic<int> instead?

2 Answers
Related