# C++20의 작은 문법 설탕: for 루프가 한결 간결해졌다

Original title: C++20 Improved the For-Loop Syntax

> Hacker News story 48873275 · language: ko · submitted 2026-07-11
> Web version: https://zeli.app/ko/story/48873275
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 14 · by [jpmitchell](<https://news.ycombinator.com/user?id=jpmitchell>) · 💬 9
[original](<https://lzon.ca/posts/tips/cpp-for-range-init/>) · [HN discussion](<https://news.ycombinator.com/item?id=48873275>)

## Summary

C++20에 도입된 '초기화 구문을 포함한 범위 기반 for 루프'는 인덱스와 요소를 함께 다루는 반복문을 한 줄로 작성할 수 있게 해준다. 기존 C++17 방식에서는 인덱스 변수와 요소 참조를 별도로 선언해야 했지만, 이제는 for 루프 초기화 부분에서 인덱스를 선언하고 범위 기반 for로 요소를 순회할 수 있다. Python의 enumerate나 Lua의 ipairs와 유사한 패턴을 C++에서도 자연스럽게 사용할 수 있게 된 것이다.

## Key quote

> 작은 문법 설탕 조각들이 코드베이스 전체에 걸쳐 사용될 때 큰 이익을 가져다줍니다.

---

## Cite

- Page: https://zeli.app/ko/story/48873275
- Date: 2026-07-11
- Source: lzon.ca (https://lzon.ca/posts/tips/cpp-for-range-init/)
- Hacker News: https://news.ycombinator.com/item?id=48873275

## Other languages

- en: https://zeli.app/story/48873275 · markdown: https://zeli.app/story/48873275.md
- zh: https://zeli.app/zh/story/48873275 · markdown: https://zeli.app/zh/story/48873275.md
- ja: https://zeli.app/ja/story/48873275 · markdown: https://zeli.app/ja/story/48873275.md
- de: https://zeli.app/de/story/48873275 · markdown: https://zeli.app/de/story/48873275.md
- es: https://zeli.app/es/story/48873275 · markdown: https://zeli.app/es/story/48873275.md
