blob: f944f27d0d73b20c7aa500a68729dab56e34025d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#pragma once
#include "std/iterator_facade.hpp"
namespace detail
{
struct Dummy
{
template <class T> Dummy & operator=(T const &) { return *this; }
};
}
class CounterIterator :
public iterator_facade<CounterIterator, detail::Dummy, forward_traversal_tag>
{
size_t m_count;
public:
CounterIterator() : m_count(0) {}
size_t GetCount() const { return m_count; }
detail::Dummy & dereference() const
{
static detail::Dummy dummy;
return dummy;
}
void increment() { ++m_count; }
};
|