Constructor call using auto on the left side

#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 about creating an object with a car 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?

+5
source share

Source: https://habr.com/ru/post/1207682/


All Articles