<分区>
基于sequence.begin()/end()/++
的c++ sequence-for,但是普通数组如int a[10];
可以也执行此操作。为什么?是否存在从普通数组到 std::array
的隐式转换?
标签 c++
<分区>
基于sequence.begin()/end()/++
的c++ sequence-for,但是普通数组如int a[10];
可以也执行此操作。为什么?是否存在从普通数组到 std::array
的隐式转换?
最佳答案
对于普通数组 range-for使用特殊处理:
If
range_expression
is an expression of array type, thenbegin_expr
is__range
andend_expr
is(__range + __bound)
, where__bound
is the number of elements in the array (if the array has unknown size or is of an incomplete type, the program is ill-formed)
关于c++对普通数组执行序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52514842/