0

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?

Shylock Hg
  • 23
  • 4

1 Answers1

1

For plain arrays range-for uses special handling:

If range_expression is an expression of array type, then begin_expr is __range and end_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