A trivial output iterator that counts assignments. More...
#include <TrivialOutputIterator.h>
Public Types | |
typedef Base::iterator_category | iterator_category |
The iterator category. | |
typedef Base::value_type | value_type |
The type "pointed to" by the iterator. | |
typedef Base::difference_type | difference_type |
Distance between iterators is represented as this type. | |
typedef Base::pointer | pointer |
This type represents a pointer-to-value_type. | |
typedef Base::reference | reference |
This type represents a reference-to-value_type. | |
Public Member Functions | |
Constructors etc. | |
TrivialOutputIteratorCount (int &count) | |
Construct from a count variable. | |
TrivialOutputIteratorCount (const TrivialOutputIteratorCount &other) | |
Copy constructor. | |
Functionality | |
template<typename Value > | |
TrivialOutputIteratorCount & | operator= (const Value &) |
Assignment of the "value type". | |
int | get () const |
Return the number of assignments. | |
void | reset () |
Reset the assignment count to zero. | |
TrivialOutputIteratorCount & | operator* () |
Dereference. | |
TrivialOutputIteratorCount & | operator++ () |
Pre-increment. | |
TrivialOutputIteratorCount & | operator++ (int) |
Post-increment. |
A trivial output iterator that counts assignments.
This is useful when you need a null container. When a function writes to an output iterator, but you do not need that result, you can use this trivial output iterator.
TrivialOutputIteratorCount& TrivialOutputIteratorCount::operator++ | ( | int | ) | [inline] |
Post-increment.
Usually one returns the object and not a reference to it. Here I need to return a reference for the counting to work.
Reimplemented from TrivialOutputIterator.