|
|
@ -6,19 +6,21 @@ |
|
|
|
//
|
|
|
|
|
|
|
|
/*
|
|
|
|
USAGE: |
|
|
|
"for(auto x : counted(v)) { ... x.value ... x.index ... }" |
|
|
|
x.value is a reference to the element in the container (so you can change it's value), x.index is what it is. |
|
|
|
Container should havae forward iterators. |
|
|
|
|
|
|
|
USAGE: |
|
|
|
"for(auto x : counted(v)) { ... x.value ... x.index ... }" |
|
|
|
x.value is a reference to the element in the container (so you can change it's value), x.index is what it is. |
|
|
|
Container should havae forward iterators. |
|
|
|
NOTE: |
|
|
|
This headers is purely a handy tool for the "for(auto x : counter(v))"-syntax. Using it explicitly with iterators is not recommended! |
|
|
|
|
|
|
|
NOTE: |
|
|
|
This headers is purely a handy tool for the "for(auto x : counter(v))"-syntax. Using it explicitly with iterators is not recommended! |
|
|
|
NOTE: |
|
|
|
There is no const version of it. Doing "for(const auto x : counted(v))" doesn't make it impossible to change x (so the element in the container can be modified). |
|
|
|
*/ |
|
|
|
|
|
|
|
NOTE: |
|
|
|
There is no const version of it. Doing "for(const auto x : counted(v))" doesn't make it impossible to change x (so the element in the container can be modified). |
|
|
|
#ifndef COUNTING_ITERATOR_HPP |
|
|
|
#define COUNTING_ITERATOR_HPP |
|
|
|
|
|
|
|
*/ |
|
|
|
#include <iterator> |
|
|
|
|
|
|
|
// A reference is a struct, yuk...
|
|
|
@ -102,3 +104,5 @@ counting_container<Container, Integer> counted(Container& c){ |
|
|
|
return counting_container<Container, Integer>(c); |
|
|
|
} |
|
|
|
|
|
|
|
#endif // COUNTING_ITERATOR_HPP
|
|
|
|
|
|
|
|