hid*_*yat 5 c++ constructor auto c++11
#include <iostream>
using namespace std;
struct A {
A() { cout << "default" << endl; }
A(const A&) { cout << "copy" << endl; }
A(A&&) { cout << "move" << endl; }
};
int main() {
A a{};
auto aa = A{};
return 0;
}
Run Code Online (Sandbox Code Playgroud)
该程序将打印default,default在MSVC2013.标准是否表示在左侧创建带有auto的对象,或者第二个版本,auto aa = A{};首先调用默认构造函数然后将tmp变量移动/复制到左侧?