Strange behavior of copy-initialization, doesn't call the copy-constructor!

前端 未结 6 699
时光说笑
时光说笑 2021-01-02 13:15

I was reading the difference between direct-initialization and copy-initialization (§8.5/12):

T x(a);  //direct-initialization
T y = a; //copy-initialization         


        
6条回答
  •  时光取名叫无心
    2021-01-02 13:26

    Here you can find this (with your comment ;)):

    [the standard] also says that the temporary copy can be elided, but the semantic constraints (eg. accessibility) of the copy constructor still have to be checked.

提交回复
热议问题