Quantcast
Channel: In C++, why does auto not work with std::atomic? - Stack Overflow
Browsing index pages (2 articles)

In C++, why does auto not work with std::atomic?

General recommendation online seems to be to use auto where possible.But this doesn't work:auto cnt = std::atomic<int>{0};While this works fine:std::atomic<int> cnt {0};Is there a...

View Article


Answer by Justin for In C++, why does auto not work with std::atomic?

std::atomic is immovable because it has a deleted copy constructor. Prior to C++17, auto cnt = std::atomic<int>{0}; tries to call the move constructor to move the temporary into cnt, so you can't...

View Article

Browsing index pages (2 articles)


Latest Images