Visual studio C++;Visual Studio 2013中的lambdas:捕获此指针

Visual studio C++;Visual Studio 2013中的lambdas:捕获此指针,visual-studio,c++11,Visual Studio,C++11,看起来,如果lambda是在一个成员函数中定义的,并且它被捕获,那么在lambda中,所有类成员都可以访问,而不需要使用这个关键字,这就是我可以做的 some_class_field = .... 而不是 this->some_class_field = .... 它是可移植的行为还是特定于VisualStudio 谢谢。预计: §5.1.2第7段 lambda表达式的复合语句生成函数调用运算符的函数体(8.4), 但出于名称查找(3.4)、确定此(9.3.2)的类型和值以及转换ide

看起来,如果lambda是在一个成员函数中定义的,并且它被捕获,那么在lambda中,所有类成员都可以访问,而不需要使用这个关键字,这就是我可以做的

some_class_field = ....
而不是

this->some_class_field = ....
它是可移植的行为还是特定于VisualStudio

谢谢。

预计:

§5.1.2第7段

lambda表达式的复合语句生成函数调用运算符的函数体(8.4), 但出于名称查找(3.4)、确定此(9.3.2)的类型和值以及转换idexpressions的目的 使用(*this)(9.3.1)将非静态类成员引用到类成员访问表达式中, 在lambda表达式的上下文中考虑复合语句。[示例:

struct S1 {
    int x, y;
    int operator()(int);
    void f() {
        [=]()->int {
            return operator()(this->x + y); // equivalent to S1::operator()(this->x + (*this).y)
        // this has type S1*
        };
    }
};