编译此代码时:
#include <future>
#include <iostream>
int main() {
std::future<int> result(std::async(
[](int m, int n) { return m + n; }, 2, 4));
std::cout << "from main" << std::endl;
std::cout << "from asnyc: " << result.get() << std::endl;
return 0;
}
与
clang++ -std=c++11 -stdlib=libc++ -Weverything promises2.cc -o promises2
我收到了警告:
promises2.cc:6:17: warning: lambda expressions are incompatible with C++98
promises2.cc:5:29: warning: local type '(lambda at promises2.cc:6:17)' as
template argument is incompatible with C++98
这些是警告,但它们是否应该是可能出错的信号? Aren&lt; lambda 认为与C ++ 98不兼容?这些警告应该告诉我的意外是什么?