This is a question on the usage of std::async in Visual Studio 11 Beta. Given the following code:
#include <future>
#include <functional>
int main()
{
std::function<int ()> f0 = []()
{
return 22;
};
std::async(f0); // Fine.
std::function<int (int)> f1 = [](int)
{
return 22;
};
std::async(f1, 11); // Fine.
std::function<int (int, int)> f2 = [](int, int)
{
return 22;
};
std::async(f2, 11, 22); // Fails compilation.
std::async(std::launch::any, f2, 11, 22); // Fine.
return 0;
}
The line that fails compilation fails with an error message that seems to imply that f2 is interpreted as a Callable that takes a single argument. The line right after it doesn't suffer from the problem. The only difference between the two is that a launch
policy is defined. The two lines should have no functional differences.
The line that fails does work under Visual Studio 2010 with
just::thread's implementation of <future>.
Is this normal?