Question:
Which of the following is NOT an atomic operation?
Answer
operator++()
operator++() on an atomic variable is NOT atomic by default. You should use fetch_add(1) instead for atomic increment.isn’t this wrong?It is mentioned earlier in the article as well:
std::atomic<int> counter{0};
counter++; // Equivalent to fetch_add(1)
Also the following link from cppreference confirms it.