@@ -34,6 +34,7 @@ namespace xt
3434 using difference_type = std::ptrdiff_t ;
3535
3636 using const_iterator = pystrides_iterator<N>;
37+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
3738
3839 pystrides_adaptor () = default ;
3940 pystrides_adaptor (const_pointer data, size_type size);
@@ -51,6 +52,11 @@ namespace xt
5152 const_iterator cbegin () const ;
5253 const_iterator cend () const ;
5354
55+ const_reverse_iterator rbegin () const ;
56+ const_reverse_iterator rend () const ;
57+ const_reverse_iterator crbegin () const ;
58+ const_reverse_iterator crend () const ;
59+
5460 private:
5561
5662 const_pointer p_data;
@@ -114,6 +120,7 @@ namespace xt
114120 ++p_current;
115121 return tmp;
116122 }
123+
117124 inline self_type operator --(int )
118125 {
119126 self_type tmp (*this );
@@ -143,11 +150,10 @@ namespace xt
143150 return self_type (p_current - n);
144151 }
145152
146- inline self_type operator -(const self_type& rhs) const
153+ inline difference_type operator -(const self_type& rhs) const
147154 {
148155 self_type tmp (*this );
149- tmp -= (p_current - rhs.p_current );
150- return tmp;
156+ return p_current - rhs.p_current ;
151157 }
152158
153159 pointer get_pointer () const { return p_current; }
@@ -262,6 +268,30 @@ namespace xt
262268 {
263269 return const_iterator (p_data + m_size);
264270 }
271+
272+ template <std::size_t N>
273+ inline auto pystrides_adaptor<N>::rbegin() const -> const_reverse_iterator
274+ {
275+ return crbegin ();
276+ }
277+
278+ template <std::size_t N>
279+ inline auto pystrides_adaptor<N>::rend() const -> const_reverse_iterator
280+ {
281+ return crend ();
282+ }
283+
284+ template <std::size_t N>
285+ inline auto pystrides_adaptor<N>::crbegin() const -> const_reverse_iterator
286+ {
287+ return const_reverse_iterator (cend ());
288+ }
289+
290+ template <std::size_t N>
291+ inline auto pystrides_adaptor<N>::crend() const -> const_reverse_iterator
292+ {
293+ return const_reverse_iterator (cbegin ());
294+ }
265295}
266296
267297#endif
0 commit comments