Copy constructor curly braces initialization

若如初见. 提交于 2019-11-29 10:34:13

I think the behaviour conforms with 8.5.4 (List initialization), sentence 3:

List-initialization of an object or reference of type T is defined as follows:

— If T is an aggregate, aggregate initialization is performed (8.5.1).

[...]

— Otherwise, if the initializer list has a single element of type E [...] the object or reference is initialized from that element;

You were expecting the second item in my abbreviated quote to apply, but the first item takes precedence: Since Data is indeed an aggregate, the one-element-list clause is never considered.


Your quote from the book appears to be a known error. The language is allegedly going to be fixed to match the book in C++14.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!