Can you read the value of std::atomic_flag without modifying it?
You cannot read the value of a std::atomic_flag without setting it to true. This is by design. It is not a boolean variable (we have std::atomic<bool> for that), but a minimal flag that is guaranteed lock free on all architectures that support C++11. On some platforms the only atomic instructions are exchange instructions. On such …