I see that this is potentially answered in question Must I call atomic load/store explicitly?.
So for sake of clarity I will restate my question succinctly in the hopes that future readers find this clear.
Is
std::atomic<bool> b(false);
bool x = b;
Same as
std::atomic<bool> b(false);
bool x = b.load();
And
std::atomic<bool> b(false);
b = true;
Same as
std::atomic<bool> b(false);
b.store(true);
If this is indeed the case then:
- why have 2 options? what is the apparent benefit?
- Is it good practice when dealing with atomics to prefer the more verbose load()/store() over the potentially confusing assignment(=) which could mean either depending on whether LHS or RHS is the atomic.
NOTE I am already aware of the fact that both variables cannot be std::atomic i.e LHS and RHS as it is not possible to read and write atomically in one instruction.