Quantcast
Channel: User HolyBlackCat - Stack Overflow
Viewing all articles
Browse latest Browse all 1285

Answer by HolyBlackCat for C++20 std::async with template lambda of zero arguments

$
0
0

Just for completeness, if upgrading to C++23 is an option and the lambda is non-capturing, you can make it static:

#include <future>#include <array>int main(){    auto func = []<int n>() static    {        std::array<double, n> arr;        };    func.operator()<5>(); // This compiles.    std::async(func.operator()<5>); // This also compiles.}

Viewing all articles
Browse latest Browse all 1285

Trending Articles



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