1 /* Ptr_Iterator class implementation: inline functions.
2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4
5 This file is part of the Parma Polyhedra Library (PPL).
6
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23
24 #ifndef PPL_Ptr_Iterator_inlines_hh
25 #define PPL_Ptr_Iterator_inlines_hh 1
26
27 namespace Parma_Polyhedra_Library {
28
29 namespace Implementation {
30
31 template <typename P>
32 inline const P&
base() const33 Ptr_Iterator<P>::base() const {
34 return p;
35 }
36
37 template <typename P>
38 inline
Ptr_Iterator()39 Ptr_Iterator<P>::Ptr_Iterator()
40 : p(P()) {
41 }
42
43 template <typename P>
44 inline
Ptr_Iterator(const P & q)45 Ptr_Iterator<P>::Ptr_Iterator(const P& q)
46 : p(q) {
47 }
48
49 template <typename P>
50 template <typename Q>
51 inline
Ptr_Iterator(const Ptr_Iterator<Q> & q)52 Ptr_Iterator<P>::Ptr_Iterator(const Ptr_Iterator<Q>& q)
53 : p(q.base()) {
54 }
55
56 template <typename P>
57 inline typename Ptr_Iterator<P>::reference
operator *() const58 Ptr_Iterator<P>::operator*() const {
59 return *p;
60 }
61
62 template <typename P>
63 inline typename Ptr_Iterator<P>::pointer
operator ->() const64 Ptr_Iterator<P>::operator->() const {
65 return p;
66 }
67
68 template <typename P>
69 inline typename Ptr_Iterator<P>::reference
operator [](const difference_type m) const70 Ptr_Iterator<P>::operator[](const difference_type m) const {
71 return p[m];
72 }
73
74 template <typename P>
75 inline Ptr_Iterator<P>&
operator ++()76 Ptr_Iterator<P>::operator++() {
77 ++p;
78 return *this;
79 }
80
81 template <typename P>
82 inline Ptr_Iterator<P>
operator ++(int)83 Ptr_Iterator<P>::operator++(int) {
84 return Ptr_Iterator(p++);
85 }
86
87 template <typename P>
88 inline Ptr_Iterator<P>&
operator --()89 Ptr_Iterator<P>::operator--() {
90 --p;
91 return *this;
92 }
93
94 template <typename P>
95 inline Ptr_Iterator<P>
operator --(int)96 Ptr_Iterator<P>::operator--(int) {
97 return Ptr_Iterator(p--);
98 }
99
100
101 template <typename P>
102 inline Ptr_Iterator<P>&
operator +=(const difference_type m)103 Ptr_Iterator<P>::operator+=(const difference_type m) {
104 p += m;
105 return *this;
106 }
107
108 template <typename P>
109 inline Ptr_Iterator<P>&
operator -=(const difference_type m)110 Ptr_Iterator<P>::operator-=(const difference_type m) {
111 p -= m;
112 return *this;
113 }
114
115 template <typename P>
116 inline typename Ptr_Iterator<P>::difference_type
operator -(const Ptr_Iterator & y) const117 Ptr_Iterator<P>::operator-(const Ptr_Iterator& y) const {
118 return p - y.p;
119 }
120
121 template <typename P>
122 inline Ptr_Iterator<P>
operator +(const difference_type m) const123 Ptr_Iterator<P>::operator+(const difference_type m) const {
124 return Ptr_Iterator(p + m);
125 }
126
127 template <typename P>
128 inline Ptr_Iterator<P>
operator -(const difference_type m) const129 Ptr_Iterator<P>::operator-(const difference_type m) const {
130 return Ptr_Iterator(p - m);
131 }
132
133 template<typename P, typename Q>
134 inline bool
operator ==(const Ptr_Iterator<P> & x,const Ptr_Iterator<Q> & y)135 operator==(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
136 return x.base() == y.base();
137 }
138
139 template<typename P, typename Q>
140 inline bool
operator !=(const Ptr_Iterator<P> & x,const Ptr_Iterator<Q> & y)141 operator!=(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
142 return x.base() != y.base();
143 }
144
145 template<typename P, typename Q>
146 inline bool
operator <(const Ptr_Iterator<P> & x,const Ptr_Iterator<Q> & y)147 operator<(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
148 return x.base() < y.base();
149 }
150
151 template<typename P, typename Q>
152 inline bool
operator <=(const Ptr_Iterator<P> & x,const Ptr_Iterator<Q> & y)153 operator<=(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
154 return x.base() <= y.base();
155 }
156
157 template<typename P, typename Q>
158 inline bool
operator >(const Ptr_Iterator<P> & x,const Ptr_Iterator<Q> & y)159 operator>(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
160 return x.base() > y.base();
161 }
162
163 template<typename P, typename Q>
164 inline bool
operator >=(const Ptr_Iterator<P> & x,const Ptr_Iterator<Q> & y)165 operator>=(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
166 return x.base() >= y.base();
167 }
168
169 template<typename P, typename Q>
170 inline typename Ptr_Iterator<P>::difference_type
operator -(const Ptr_Iterator<P> & x,const Ptr_Iterator<Q> & y)171 operator-(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
172 return x.base() - y.base();
173 }
174
175 template<typename P>
176 inline Ptr_Iterator<P>
operator +(typename Ptr_Iterator<P>::difference_type m,const Ptr_Iterator<P> & y)177 operator+(typename Ptr_Iterator<P>::difference_type m,
178 const Ptr_Iterator<P>& y) {
179 return Ptr_Iterator<P>(m + y.base());
180 }
181
182 } // namespace Implementation
183
184 } // namespace Parma_Polyhedra_Library
185
186 #endif // !defined(PPL_Ptr_Iterator_inlines_hh)
187