c++ - Reference initialization in C++11 default constructor -


struct x {};  struct y {      y() = default;     x& x; }; 

works fine in c++11. wish know how y::x initialized behind scenes?

it doesn't compile in major compiler. compile, until of creation of object of type y.

if create object of type y, output of clang be

error: call implicitly-deleted default constructor of 'y' note: explicitly defaulted function implicitly deleted here     y() = default; note: default constructor of 'y' implicitly deleted because field 'x' of reference type 'x &' not initialized     x& x; 

when declare user-defined constructor, empty function, there error, without creation of object.

michael burr right. implicitly-defaulted constructor works fine. there no problems diagnostic here, can see.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -