中通过实例列举了lambda使用过程中可能会有变量生命期问题。
C++14中可以通过重新定义变量,并转移,解决这个问题:
#include <iostream>
using namespace std;
class A
{
public:
A(int data):m_data(data)
{
cout<<"Construct, this addr:"<<this<<endl;
}
A(const A& a)
{
cout<<
中通过实例列举了lambda使用过程中可能会有变量生命期问题。
C++14中可以通过重新定义变量,并转移,解决这个问题:
#include <iostream>
using namespace std;
class A
{
public:
A(int data):m_data(data)
{
cout<<"Construct, this addr:"<<this<<endl;
}
A(const A& a)
{
cout<<