The c++ sequence-for based on sequence.begin()/end()/++
,but the plain array such as int a[10];
can also perform this.Why?Is there some implicit cast from plain array to std::array
?
Asked
Active
Viewed 174 times
0

Shylock Hg
- 23
- 4
-
2Duplicate of https://stackoverflow.com/q/7939399/3002139 – Baum mit Augen Sep 26 '18 at 09:57
1 Answers
1
For plain arrays range-for uses special handling:
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)

Maxim Egorushkin
- 131,725
- 17
- 180
- 271