paludis  Version 2.6.0
wrapped_forward_iterator.hh
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
5  *
6  * This file is part of the Paludis package manager. Paludis is free software;
7  * you can redistribute it and/or modify it under the terms of the GNU General
8  * Public License version 2, as published by the Free Software Foundation.
9  *
10  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_FORWARD_ITERATOR_HH
21 #define PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_FORWARD_ITERATOR_HH 1
22 
23 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
24 #include <paludis/util/operators.hh>
26 #include <functional>
27 #include <type_traits>
28 #include <iterator>
29 
30 namespace paludis
31 {
32  /**
33  * A WrappedForwardIterator is a generic wrapper around a forward iterator,
34  * hiding the underlying base iterator.
35  *
36  * \ingroup g_iterator
37  * \since 0.26
38  */
39  template <typename Tag_, typename Value_>
40  class PALUDIS_VISIBLE WrappedForwardIterator :
41  public equality_operators::HasEqualityOperators
42  {
43  private:
44  WrappedForwardIteratorUnderlyingIteratorHolder * _iter;
45 
46  public:
47  typedef Tag_ Tag;
48 
49  ///\name Basic operations
50  ///\{
51 
52  WrappedForwardIterator();
53  ~WrappedForwardIterator();
54  WrappedForwardIterator(const WrappedForwardIterator &);
55 
56  template <typename T_>
57  WrappedForwardIterator(const T_ &);
58 
59  WrappedForwardIterator & operator= (const WrappedForwardIterator &);
60 
61  ///\}
62 
63  ///\name Standard library typedefs
64  ///\{
65 
66  typedef typename std::remove_reference<Value_>::type & value_type;
67  typedef typename std::remove_reference<Value_>::type & reference;
68  typedef typename std::remove_reference<Value_>::type * pointer;
69  typedef std::ptrdiff_t difference_type;
70  typedef std::forward_iterator_tag iterator_category;
71 
72  ///\}
73 
74  ///\name Increment
75  ///\{
76 
77  WrappedForwardIterator & operator++ ();
78  WrappedForwardIterator operator++ (int);
79 
80  ///\}
81 
82  ///\name Dereference
83  ///\{
84 
85  pointer operator-> () const;
86  reference operator* () const;
87 
88  ///\}
89 
90  ///\name Equality
91  ///\{
92 
93  bool operator== (const WrappedForwardIterator &) const;
94 
95  ///\}
96 
97  ///\name Underlying iterator
98  ///\{
99 
100  template <typename T_> T_ & underlying_iterator();
101  template <typename T_> const T_ & underlying_iterator() const;
102 
103  ///\}
104  };
105 }
106 
107 #endif
Definition: about_metadata-fwd.hh:23
#define PALUDIS_VISIBLE
Definition: attributes.hh:59
bool operator==(const PackageID &, const PackageID &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE