V
Victor Bazarov
Hello,
I'm studying lambdas and threading feature in C++11. Using some
materials from different sources, and feeling my way through...
Here is the code that gives me the trouble today:
==================================================== >8 cut here
#include <future>
int main()
{
auto foo = [](int i, int j) -> float {
float sum = 0;
for (int k = 0; k < i*j; k++)
sum += k*k;
return sum;
};
auto brr = foo(5,6); // OK
auto bar = std::async(foo(5, 6)); // line 13
}
==================================================== >8 cut here
I get a long-nested error message for line 13 from VC++ 2012 Express,
and from what I could gather it didn't like my 'return' statement or
something else. Do you see anything wrong with the code? I don't have
a way to try it on any other compiler (maybe clang? I'll try...)
Thanks!
V
I'm studying lambdas and threading feature in C++11. Using some
materials from different sources, and feeling my way through...
Here is the code that gives me the trouble today:
==================================================== >8 cut here
#include <future>
int main()
{
auto foo = [](int i, int j) -> float {
float sum = 0;
for (int k = 0; k < i*j; k++)
sum += k*k;
return sum;
};
auto brr = foo(5,6); // OK
auto bar = std::async(foo(5, 6)); // line 13
}
==================================================== >8 cut here
I get a long-nested error message for line 13 from VC++ 2012 Express,
and from what I could gather it didn't like my 'return' statement or
something else. Do you see anything wrong with the code? I don't have
a way to try it on any other compiler (maybe clang? I'll try...)
Thanks!
V