Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.02 KB

range-based-for-loop.md

File metadata and controls

46 lines (34 loc) · 1.02 KB

Range-based for-loop {#example_range_based_for_loop}

#include <cstdio>

int main()
{
    const char arr[]{2, 4, 6, 8, 10};

    for(const char& c : arr) {
        printf("c=%c\n", c);
    }
}

Here is the transformed code:

#include <cstdio>

int main()
{
  const char arr[5] = {2, 4, 6, 8, 10};
  {
    const char (&__range1)[5] = arr;
    const char * __begin1 = __range1;
    const char * __end1 = __range1 + 5L;
    for(; __begin1 != __end1; ++__begin1) {
      const char & c = *__begin1;
      printf("c=%c\n", static_cast<int>(c));
    }
    
  }
  return 0;
}

Live view