1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2012-2013. Distributed under the Boost
4// Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// See http://www.boost.org/libs/container for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10
11#ifndef BOOST_CONTAINER_TEST_FORWARD_TO_INPUT_ITERATOR_HPP
12#define BOOST_CONTAINER_TEST_FORWARD_TO_INPUT_ITERATOR_HPP
13
14#include <boost/container/detail/iterator.hpp>
15
16namespace boost{
17namespace container {
18namespace test{
19
20template<class FwdIterator>
21class input_iterator_wrapper
22 : public boost::container::iterator< std::input_iterator_tag
23 , typename boost::container::iterator_traits<FwdIterator>::value_type
24 , typename boost::container::iterator_traits<FwdIterator>::difference_type
25 , typename boost::container::iterator_traits<FwdIterator>::pointer
26 , typename boost::container::iterator_traits<FwdIterator>::reference
27 >
28{
29 FwdIterator m_it;
30
31 public:
32 input_iterator_wrapper()
33 : m_it(0)
34 {}
35
36 explicit input_iterator_wrapper(FwdIterator it)
37 : m_it(it)
38 {}
39
40 //Default copy constructor...
41 //input_iterator_wrapper(const input_iterator_wrapper&);
42
43 //Default assignment...
44 //input_iterator_wrapper &operator=(const input_iterator_wrapper&);
45
46 //Default destructor...
47 //~input_iterator_wrapper();
48
49 typename boost::container::iterator_traits<FwdIterator>::reference operator*() const
50 { return *m_it; }
51
52 typename boost::container::iterator_traits<FwdIterator>::pointer operator->() const
53 { return m_it.operator->(); }
54
55 input_iterator_wrapper& operator++()
56 { ++m_it; return *this; }
57
58 input_iterator_wrapper operator++(int )
59 {
60 input_iterator_wrapper tmp(m_it);
61 ++m_it;
62 return tmp;
63 }
64
65 friend bool operator==(const input_iterator_wrapper &left, const input_iterator_wrapper &right)
66 { return left.m_it == right.m_it; }
67
68 friend bool operator!=(const input_iterator_wrapper &left, const input_iterator_wrapper &right)
69 { return left.m_it != right.m_it; }
70};
71
72template<class FwdIterator>
73input_iterator_wrapper<FwdIterator> make_input_from_forward_iterator(const FwdIterator &it)
74{ return input_iterator_wrapper<FwdIterator>(it); }
75
76} //namespace test{
77} //namespace container {
78} //namespace boost{
79
80#endif //BOOST_CONTAINER_TEST_FORWARD_TO_INPUT_ITERATOR_HPP
81

source code of boost/libs/container/test/input_from_forward_iterator.hpp