Lambdas似乎不在VS2010的ref类中工作 [英] Lambdas don't appear to work within ref classes in VS2010
问题描述
Visual Studio 2010中酷炫的新C ++功能之一是lambda表达式。但是,我无法让他们在托管类中工作。
One of the cool new C++ features in Visual Studio 2010 are lambda expressions. However, I can't get them to work within a managed class.
class UnmanagedClass {
void Foo() {
// Creating empty lambda within unmanaged class.
// This compiles fine.
auto lambda = [](){ ; };
}
};
ref class ManagedClass {
void Foo() {
// Creating empty lambda within managed class.
// This creates error C3809:
// A managed type cannot have any friend functions/classes/interfaces.
auto lambda = [](){ ; };
}
};
我最好的猜想是编译器创建一个匿名函数类作为一个朋友类,使用类成员。这似乎意味着lambdas不能在ref类中使用。
My best guess is that the compiler creates the anonymous function class as a friend class, even though I never use class members. This seems to mean that lambdas cannot be used at all within ref classes.
当我读到VS2010将lambda表达式添加到C ++时,我很高兴。是否有人知道如何让他们在ref类中工作?
I was so happy when I read that VS2010 adds lambda expressions to C++. Does anybody know how to get them to work within ref classes?
推荐答案
看起来像它被考虑用于未来的版本。否则称为:我们会得到它。
Looks like it is being considered for future versions. Otherwise known as: "We'll get to it."
这篇关于Lambdas似乎不在VS2010的ref类中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!