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};