Quantcast
Channel: In C++, why does auto not work with std::atomic? - Stack Overflow
Browsing all 2 articles
Browse latest View live

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



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
Browsing all 2 articles
Browse latest View live




Latest Images