1// Boost.Range library
2//
3// Copyright Neil Groves 2014. Use, modification and distribution is subject
4// to the Boost Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//
8// For more information, see http://www.boost.org/libs/range
9//
10#ifndef BOOST_RANGE_UNIT_TEST_ADAPTOR_MOCK_ITERATOR_HPP_INCLUDED
11#define BOOST_RANGE_UNIT_TEST_ADAPTOR_MOCK_ITERATOR_HPP_INCLUDED
12
13#include <boost/iterator/iterator_facade.hpp>
14
15namespace boost
16{
17 namespace range
18 {
19 namespace unit_test
20 {
21
22template<typename TraversalTag>
23class mock_iterator
24 : public boost::iterator_facade<
25 mock_iterator<TraversalTag>,
26 int,
27 TraversalTag,
28 const int&
29 >
30{
31public:
32 mock_iterator()
33 : m_value(0)
34 {
35 }
36
37 explicit mock_iterator(int value)
38 : m_value(value)
39 {
40 }
41
42private:
43
44 void increment()
45 {
46 ++m_value;
47 }
48
49 void decrement()
50 {
51 --m_value;
52 }
53
54 bool equal(const mock_iterator& other) const
55 {
56 return m_value == other.m_value;
57 }
58
59 void advance(std::ptrdiff_t offset)
60 {
61 m_value += offset;
62 }
63
64 std::ptrdiff_t distance_to(const mock_iterator& other) const
65 {
66 return other.m_value - m_value;
67 }
68
69 const int& dereference() const
70 {
71 return m_value;
72 }
73
74 int m_value;
75 friend class boost::iterator_core_access;
76};
77
78 } // namespace unit_test
79 } // namespace range
80} // namespace boost
81
82#endif // include guard
83

source code of boost/libs/range/test/compile_fail/adaptor/mock_iterator.hpp