Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by Lightness Races in Orbit for in-class initialization of atomic

std::atomic<int> x = 1; is copy-initialisation, and basically does this:

std::atomic<int> x{std::atomic<int>{1}};

Your compiler actually doesn't complain about operator=, but instead about the copy constructor.

(As you've pointed out, a later operator= call works just fine.)

Do a normal initialisation:

std::atomic<int> x{1};

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>