不是人话系列,有兴趣自己看吧:
An array of narrow character type (6.9.1), char16_t array, char32_t array, or wchar_t array can be initialized by a narrow string literal, char16_t string literal, char32_t string literal, or wide string literal, respectively, or by an appropriately-typed string literal enclosed in braces (5.13.5). Successive characters of the value of the string literal initialize the elements of the array.
本来我想说“这个结合我上面贴的string literal是const char数组得出的就是我开始说的用字符串字面量初始化字符数组是把字符串字面复制到字符数组里。”不过细琢磨characters of the value of the string貌似有歧义…… 如果强调value of the string那么应该是复制string的内容,如果强调characters那么就是等价于对应的aggregate initialization,虽然结果都一样。
有关拷贝初始化的规则。
Otherwise, if the initialization is direct-initialization, or if it is copy-initialization where thecv-unqualified version of the source type is the same class as, or a derived class of, the class of thedestination, constructors are considered. The applicable constructors are enumerated (16.3.1.3), and the best one is chosen through overload resolution (16.3). The constructor so selected is called to initialize the object, with the initializer expression or expression-list as its argument(s). If no constructor applies, or the overload resolution is ambiguous, the initialization is ill-formed. (17.6.3)
Otherwise (i.e., for the remaining copy-initialization cases), user-defined conversion sequences that can convert from the source type to the destination type or (when a conversion function is used) to a derived class thereof are enumerated as described in 16.3.1.4, and the best one is chosen through overload resolution (16.3). If the conversion cannot be done or is ambiguous, the initialization is ill-formed. The function selected is called with the initializer expression as its argument; if the function is a constructor, the call is a prvalue of the cv-unqualified version of the destination type whose result object is initialized by the constructor. The call is used to direct-initialize, according to the rules above, the object that is the destination of the copy-initialization.
注意这是C++17的规范,之前的懒得找了。