https://github.com/reputeless/indexediterator
Header-only indexed iterator library for modern C++
https://github.com/reputeless/indexediterator
cpp cpp17
Last synced: 2 months ago
JSON representation
Header-only indexed iterator library for modern C++
- Host: GitHub
- URL: https://github.com/reputeless/indexediterator
- Owner: Reputeless
- License: mit
- Created: 2017-10-28T20:58:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-31T08:23:04.000Z (over 7 years ago)
- Last Synced: 2025-03-29T11:22:25.795Z (3 months ago)
- Topics: cpp, cpp17
- Language: C++
- Homepage:
- Size: 15.6 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# siv::IndexedIterator
**siv::IndexedIterator** is a header-only indexed iterator library for modern C++.## Examples
### std::vector
```cpp
std::vector v = { 0, 100, 200, 300, 400, 500 };for (auto [i, n] : Indexed(v))
{
std::cout << i << ": " << n << "\n";
}
```
```
0: 0
1: 100
2: 200
3: 300
4: 400
5: 500
```### std::string
```cpp
std::string s = "Hello, world!";for (auto [i, ch] : Indexed(v))
{
std::cout << i << ": " << ch << "\n";
}
```
```
0: H
1: e
2: l
3: l
4: o
5: ,
6:
7: w
8: o
9: r
10: l
11: d
12: !
```### std::map
```cpp
std::map m = { { "aaa", "AAA" }, { "bbb", "BBB" }, { "ccc", "CCC" } };for (auto [i, p] : Indexed(m))
{
std::cout << i << ": " << p.first << ", " << p.second << "\n";
}
```
```
0: aaa, AAA
1: bbb, BBB
2: ccc, CCC
```## License
siv::IndexedIterator is distributed under the MIT license.