|
@ -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: |
|
|
NOTE: |
|
|
"for(auto x : counted(v)) { ... x.value ... x.index ... }" |
|
|
This headers is purely a handy tool for the "for(auto x : counter(v))"-syntax. Using it explicitly with iterators is not recommended! |
|
|
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: |
|
|
NOTE: |
|
|
This headers is purely a handy tool for the "for(auto x : counter(v))"-syntax. Using it explicitly with iterators is not recommended! |
|
|
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: |
|
|
#ifndef COUNTING_ITERATOR_HPP |
|
|
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). |
|
|
#define COUNTING_ITERATOR_HPP |
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
#include <iterator> |
|
|
#include <iterator> |
|
|
|
|
|
|
|
|
// A reference is a struct, yuk...
|
|
|
// A reference is a struct, yuk...
|
|
@ -102,3 +104,5 @@ counting_container<Container, Integer> counted(Container& c){ |
|
|
return counting_container<Container, Integer>(c); |
|
|
return counting_container<Container, Integer>(c); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif // COUNTING_ITERATOR_HPP
|
|
|
|
|
|
|
|
|