atomic int c++ add 1
#include <iostream>
#include <thread>
#include <atomic>
std::atomic<int> counter(0);
int main() {
// Step 1: Increment the atomic variable by 1
counter.fetch_add(1);
// Step 2: Retrieve the updated value of the atomic variable
int currentValue = counter.load();
// Step 3: Print the updated value
std::cout << "Updated value: " << currentValue << std::endl;
return 0;
}