Continuing from the last post, we discussed atomic read, write and read-modify-write. However, we have yet to discuss arguably the most important and commonly used operation on a std::atomic, the compare-and-swap (CAS). Compare-and-Swap CAS would not be complete without the swap operation. This is available through the exchange() member function. std::atomic<int>…