Visual Studio 2010中的一个很酷的新C ++特性是lambda表达式。 但是,我无法让他们在托管类中工作。
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 = [](){ ; }; } };我最好的猜测是编译器创建匿名函数类作为朋友类,尽管我从不使用类成员。 这似乎意味着在ref类中不能使用lambda表达式。
当我读到VS2010将Lambda表达式添加到C ++时,我非常高兴。 有人知道如何让他们在裁判职位内工作吗?
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 = [](){ ; }; } };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.
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."
更多推荐
发布评论