Created
December 23, 2015 16:36
-
-
Save minjang/d248e1d489c064c20c44 to your computer and use it in GitHub Desktop.
Python's enumerate implementation in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 2. 일반 배열 예 | |
cout << "[TEST 2] array\n"; | |
string C[] = {"foo", "bar", "baz"}; | |
// auto&&로 받는 것이 범위 기반 for 문에서 일반적이고 효율적인 방법 | |
// p 타입: pair<size_t, string&>&&, 원소 타입이 string&로 추론 | |
for (auto &&p : enumerate(C, 100)) | |
cout << p.first << ": " << (p.second += p.second) << '\n'; | |
for (auto &&p : enumerate(C, 100)) | |
cout << p.first << ": " << p.second << '\n'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment