Quantcast
Channel: Use std::atomic in lambda expression - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by yuri kilochek for Use std::atomic in lambda expression

$
0
0

You can initialize the capture directly and rely on C++17 guaranteed copy/move elision:

#include <atomic>int main(){    auto check = [a = std::atomic_int(42)]() mutable {        return a.fetch_sub(1) == 1;    };}

Viewing all articles
Browse latest Browse all 2

Trending Articles



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