C++ Insights - Episode 37: C++20's range-based for-loop with initializer

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 2

  • @189Blake
    @189Blake Рік тому

    If we are going back to using variables inside the for loop, as old for loops did, what are the advantages of using a range-based for-loop?

    • @andreas_fertig
      @andreas_fertig  Рік тому

      Good point. The range-based for-loop still provides a safe method to access the elements. The addition variable would not create an out-of-bounds access... at least in my example.