<div dir="ltr"><div><div>for the following code:<br><br>struct X<br>{<br> X();<br>};<br><br>struct Y<br>{<br> operator X() const;<br>};<br><br>X a = { Y() }; // reports error: no matching constructor for initialization of 'X'<br>
X aa = Y(); // works fine<br><br><br></div>clang when compiled with std=c++11 gives compilation errors as:<br><br><br>testfile.C:11:3: error: no matching constructor for initialization of 'X'<br>X a = { Y() }; // reports error: no matching constructor for initialization of 'X'<br>
^ ~~~~~~~<br>testfile.C:1:8: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Y' to 'const X &' for 1st<br> argument<br>struct X<br> ^<br>
testfile.C:1:8: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'Y' to 'X &&' for 1st<br> argument<br>struct X<br> ^<br>testfile.C:3:3: note: candidate constructor not viable: requires 0 arguments, but 1 was provided<br>
X();<br> ^<br>1 error generated.<br><br><br></div><div><br><br><div><br clear="all"><br>-- <br><div>Thanx & Regards <br></div>
<div><b>Mayur Pandey </b><br></div><div>+91-9742959541<br><font color="#3333ff"></font><font color="#3333ff"> <br></font></div>
<div> </div>
<div> </div>
</div></div></div>