std::atomic<bool> is a full-featured atomic Boolean type compared to std::atomic_flag. But neither copy-construction nor assignment is possible with this type. The value of an std::atomic<bool> object can initially be either true or false. The objects of this type can be constructed or assigned values from a non-atomic bool:

std::atomic<bool> flg(true);flg = false;

One thing needs to be noted about the assignment operator of atomic types, which is that the operator returns the value of non-atomic types rather than the conventional scheme of returning references. If a reference is returned instead of a value, it would create a situation where the result of assignment gets the result of a modification by another thread, that ...

Get C++ Reactive Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.