Call constructor using auto on the left side

62 Views Asked by At
#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;
}

This program will print default, default in MSVC2013. Does the standard say anything of creating an object with auto on the left side, or can the second version, auto aa = A{}; first call the default constructor and then move/copy the tmp variable to the left side?

0

There are 0 best solutions below