[英]What does [](int* p){delete p;} mean?
Could someone help me to understand what 有人可以帮助我理解什么
[](int* p){delete p;}
means? 手段?
I found it in the docs. 我在文档中找到了它。 for shared_ptr http://www.cplusplus.com/reference/memory/shared_ptr/shared_ptr/
for shared_ptr http://www.cplusplus.com/reference/memory/shared_ptr/shared_ptr/
It's a capture-less lambda expression that takes a pointer to an int
and calls delete
on it. 它是一个无捕获的lambda表达式 ,它接受指向
int
的指针并在其上调用delete
。 Here's another MSDN link that explains the grammar of lambdas. 这是另一个解释lambdas语法的MSDN链接。
This denotes a C++11-style lambda expression ("lambda function"). 这表示C ++ 11风格的lambda表达式 (“lambda函数”)。 It takes a pointer to an integer and
delete
s it. 它需要一个指向整数的指针并
delete
它。
it is similar to 它类似于
void foo(int* p){
delete p;
}
but can be written inline as part of another function (for example to be passed as a callback). 但可以作为另一个函数的一部分内联编写(例如作为回调传递)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.