1/* Copyright 2016 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
5 *
6 * See http://www.boost.org/libs/poly_collection for library home page.
7 */
8
9#ifndef BOOST_POLY_COLLECTION_DETAIL_AUTO_ITERATOR_HPP
10#define BOOST_POLY_COLLECTION_DETAIL_AUTO_ITERATOR_HPP
11
12#if defined(_MSC_VER)
13#pragma once
14#endif
15
16#include <boost/iterator/iterator_adaptor.hpp>
17
18namespace boost{
19
20namespace poly_collection{
21
22namespace detail{
23
24/* auto_iterator<Iterator> (for want of a better name) behaves like Iterator
25 * save for the fact that it derefs to Iterator& rather than
26 * Iterator::reference. This is useful to "lift" std algorithms so that
27 * user-defined predicates are passed iterators that can then be dereferenced
28 * internally.
29 */
30
31template<typename Iterator>
32class auto_iterator:
33 public boost::iterator_adaptor<auto_iterator<Iterator>,Iterator,Iterator>
34{
35public:
36 auto_iterator()=default;
37 auto_iterator(const Iterator& it):auto_iterator::iterator_adaptor_{it}{}
38 auto_iterator(const auto_iterator&)=default;
39 auto_iterator& operator=(const auto_iterator&)=default;
40
41private:
42 friend class boost::iterator_core_access;
43
44 Iterator& dereference()const noexcept
45 {
46 return const_cast<auto_iterator*>(this)->base_reference();
47 }
48};
49
50} /* namespace poly_collection::detail */
51
52} /* namespace poly_collection */
53
54} /* namespace boost */
55
56#endif
57

source code of boost/libs/poly_collection/include/boost/poly_collection/detail/auto_iterator.hpp