@@ -81,18 +81,17 @@ namespace xt
8181 using size_type = std::size_t ;
8282 using difference_type = std::ptrdiff_t ;
8383
84- using stepper = xstepper<self_type>;
85- using const_stepper = xstepper<const self_type>;
86-
87- using iterator = xiterator<stepper>;
88- using const_iterator = xiterator<const_stepper>;
89-
9084 using storage_iterator = T*;
9185 using const_storage_iterator = const T*;
9286
9387 using shape_type = std::vector<size_type>;
9488 using strides_type = std::vector<size_type>;
9589 using backstrides_type = pyarray_backstrides<self_type>;
90+
91+ using stepper = xstepper<self_type>;
92+ using const_stepper = xstepper<const self_type>;
93+ using iterator = xiterator<stepper, shape_type>;
94+ using const_iterator = xiterator<const_stepper, shape_type>;
9695
9796 using closure_type = const self_type&;
9897
@@ -153,13 +152,18 @@ namespace xt
153152 const_iterator cbegin () const ;
154153 const_iterator cend () const ;
155154
156- iterator xbegin (const shape_type& shape);
157- iterator xend (const shape_type& shape);
158-
159- const_iterator xbegin (const shape_type& shape) const ;
160- const_iterator xend (const shape_type& shape) const ;
161- const_iterator cxbegin (const shape_type& shape) const ;
162- const_iterator cxend (const shape_type& shape) const ;
155+ template <class S >
156+ xiterator<stepper, S> xbegin (const S& shape);
157+ template <class S >
158+ xiterator<stepper, S> xend (const S& shape);
159+ template <class S >
160+ xiterator<const_stepper, S> xbegin (const S& shape) const ;
161+ template <class S >
162+ xiterator<const_stepper, S> xend (const S& shape) const ;
163+ template <class S >
164+ xiterator<const_stepper, S> cxbegin (const S& shape) const ;
165+ template <class S >
166+ xiterator<const_stepper, S> cxend (const S& shape) const ;
163167
164168 stepper stepper_begin (const shape_type& shape);
165169 stepper stepper_end (const shape_type& shape);
@@ -169,9 +173,10 @@ namespace xt
169173
170174 storage_iterator storage_begin ();
171175 storage_iterator storage_end ();
172-
173176 const_storage_iterator storage_begin () const ;
174177 const_storage_iterator storage_end () const ;
178+ const_storage_iterator storage_cbegin () const ;
179+ const_storage_iterator storage_cend () const ;
175180
176181 template <class E >
177182 pyarray (const xexpression<E>& e);
@@ -427,37 +432,43 @@ namespace xt
427432 }
428433
429434 template <class T , int ExtraFlags>
430- inline auto pyarray<T, ExtraFlags>::xbegin(const shape_type& shape) -> iterator
435+ template <class S >
436+ inline auto pyarray<T, ExtraFlags>::xbegin(const S& shape) -> xiterator<stepper, S>
431437 {
432- return iterator (stepper_begin (shape), shape);
438+ return xiterator<stepper, S> (stepper_begin (shape), shape);
433439 }
434440
435441 template <class T , int ExtraFlags>
436- inline auto pyarray<T, ExtraFlags>::xend(const shape_type& shape) -> iterator
442+ template <class S >
443+ inline auto pyarray<T, ExtraFlags>::xend(const S& shape) -> xiterator<stepper, S>
437444 {
438- return iterator (stepper_end (shape), shape);
445+ return xiterator<stepper, S> (stepper_end (shape), shape);
439446 }
440447
441448 template <class T , int ExtraFlags>
442- inline auto pyarray<T, ExtraFlags>::xbegin(const shape_type& shape) const -> const_iterator
449+ template <class S >
450+ inline auto pyarray<T, ExtraFlags>::xbegin(const S& shape) const -> xiterator<const_stepper, S>
443451 {
444- return const_iterator (stepper_begin (shape), shape);
452+ return xiterator<const_stepper, S> (stepper_begin (shape), shape);
445453 }
446454
447455 template <class T , int ExtraFlags>
448- inline auto pyarray<T, ExtraFlags>::xend(const shape_type& shape) const -> const_iterator
456+ template <class S >
457+ inline auto pyarray<T, ExtraFlags>::xend(const S& shape) const -> xiterator<const_stepper, S>
449458 {
450- return const_iterator (stepper_end (shape), shape);
459+ return xiterator<const_stepper, S> (stepper_end (shape), shape);
451460 }
452461
453462 template <class T , int ExtraFlags>
454- inline auto pyarray<T, ExtraFlags>::cxbegin(const shape_type& shape) const -> const_iterator
463+ template <class S >
464+ inline auto pyarray<T, ExtraFlags>::cxbegin(const S& shape) const -> xiterator<const_stepper, S>
455465 {
456466 return xbegin (shape);
457467 }
458468
459469 template <class T , int ExtraFlags>
460- inline auto pyarray<T, ExtraFlags>::cxend(const shape_type& shape) const -> const_iterator
470+ template <class S >
471+ inline auto pyarray<T, ExtraFlags>::cxend(const S& shape) const -> xiterator<const_stepper, S>
461472 {
462473 return xend (shape);
463474 }
@@ -514,6 +525,18 @@ namespace xt
514525 return storage_begin () + pybind_array::size ();
515526 }
516527
528+ template <class T , int ExtraFlags>
529+ inline auto pyarray<T, ExtraFlags>::storage_cbegin() const -> const_storage_iterator
530+ {
531+ return reinterpret_cast <const_storage_iterator>(pybind11::backport::array_proxy (m_ptr)->data );
532+ }
533+
534+ template <class T , int ExtraFlags>
535+ inline auto pyarray<T, ExtraFlags>::storage_cend() const -> const_storage_iterator
536+ {
537+ return storage_begin () + pybind_array::size ();
538+ }
539+
517540 template <class T , int ExtraFlags>
518541 template <class E >
519542 inline pyarray<T, ExtraFlags>::pyarray(const xexpression<E>& e)
0 commit comments