If I write this
std::function<int()> myFunction = []() {return 42;};
in C++/CLI under VS2010 (in an MSTest unit test class, in case it matters), I get the compiler error C3809: a managed type cannot have any friend functions/classes/interfaces
.
Is a lambda considered as a friend because it cooooould access local variables, even if it doesn't?
On the other hand, this works fine:
int ThatOldJokeAgain()
{
return 42;
}
[...]
std::function<int()> myFunction2 = ThatOldJokeAgain;
Is there a way to make lambdas work in C++/CLI? Or is my error something completely different?