1818#include " xtensor/xexpression.hpp"
1919#include " xtensor/xsemantic.hpp"
2020#include " xtensor/xiterator.hpp"
21+ #include " xtensor/xcontainer.hpp"
2122
2223namespace xt
2324{
@@ -110,17 +111,17 @@ namespace xt
110111 using size_type = std::size_t ;
111112 using difference_type = std::ptrdiff_t ;
112113
113- using storage_iterator = T*;
114- using const_storage_iterator = const T*;
114+ using iterator = T*;
115+ using const_iterator = const T*;
115116
116117 using shape_type = std::vector<size_type>;
117118 using strides_type = std::vector<size_type>;
118119 using backstrides_type = pyarray_backstrides<self_type>;
119120
120121 using stepper = xstepper<self_type>;
121122 using const_stepper = xstepper<const self_type>;
122- using iterator = xiterator<stepper, shape_type>;
123- using const_iterator = xiterator<const_stepper, shape_type>;
123+ using broadcast_iterator = xiterator<stepper, shape_type* >;
124+ using const_broadcast_iterator = xiterator<const_stepper, shape_type* >;
124125
125126 using closure_type = const self_type&;
126127
@@ -173,13 +174,13 @@ namespace xt
173174 template <class S >
174175 bool is_trivial_broadcast (const S& strides) const ;
175176
176- iterator begin ();
177- iterator end ();
177+ broadcast_iterator xbegin ();
178+ broadcast_iterator xend ();
178179
179- const_iterator begin () const ;
180- const_iterator end () const ;
181- const_iterator cbegin () const ;
182- const_iterator cend () const ;
180+ const_broadcast_iterator xbegin () const ;
181+ const_broadcast_iterator xend () const ;
182+ const_broadcast_iterator cxbegin () const ;
183+ const_broadcast_iterator cxend () const ;
183184
184185 template <class S >
185186 xiterator<stepper, S> xbegin (const S& shape);
@@ -204,12 +205,12 @@ namespace xt
204205 template <class S >
205206 const_stepper stepper_end (const S& shape) const ;
206207
207- storage_iterator storage_begin ();
208- storage_iterator storage_end ();
209- const_storage_iterator storage_begin () const ;
210- const_storage_iterator storage_end () const ;
211- const_storage_iterator storage_cbegin () const ;
212- const_storage_iterator storage_cend () const ;
208+ iterator begin ();
209+ iterator end ();
210+ const_iterator begin () const ;
211+ const_iterator end () const ;
212+ const_iterator cbegin () const ;
213+ const_iterator cend () const ;
213214
214215 template <class E >
215216 pyarray (const xexpression<E>& e);
@@ -444,67 +445,67 @@ namespace xt
444445 }
445446
446447 template <class T , int ExtraFlags>
447- inline auto pyarray<T, ExtraFlags>::begin () -> iterator
448+ inline auto pyarray<T, ExtraFlags>::xbegin () -> broadcast_iterator
448449 {
449- return xbegin ( shape () );
450+ return broadcast_iterator ( stepper_begin (m_shape), &m_shape );
450451 }
451452
452453 template <class T , int ExtraFlags>
453- inline auto pyarray<T, ExtraFlags>::end () -> iterator
454+ inline auto pyarray<T, ExtraFlags>::xend () -> broadcast_iterator
454455 {
455- return xend ( shape () );
456+ return broadcast_iterator ( stepper_end (m_shape), &m_shape );
456457 }
457458
458459 template <class T , int ExtraFlags>
459- inline auto pyarray<T, ExtraFlags>::begin () const -> const_iterator
460+ inline auto pyarray<T, ExtraFlags>::xbegin () const -> const_broadcast_iterator
460461 {
461- return xbegin ( shape () );
462+ return const_broadcast_iterator ( stepper_begin (m_shape), &m_shape );
462463 }
463464
464465 template <class T , int ExtraFlags>
465- inline auto pyarray<T, ExtraFlags>::end () const -> const_iterator
466+ inline auto pyarray<T, ExtraFlags>::xend () const -> const_broadcast_iterator
466467 {
467- return xend ( shape () );
468+ return const_broadcast_iterator ( stepper_end (m_shape), &m_shape );
468469 }
469470
470471 template <class T , int ExtraFlags>
471- inline auto pyarray<T, ExtraFlags>::cbegin () const -> const_iterator
472+ inline auto pyarray<T, ExtraFlags>::cxbegin () const -> const_broadcast_iterator
472473 {
473- return begin ();
474+ return xbegin ();
474475 }
475476
476477 template <class T , int ExtraFlags>
477- inline auto pyarray<T, ExtraFlags>::cend () const -> const_iterator
478+ inline auto pyarray<T, ExtraFlags>::cxend () const -> const_broadcast_iterator
478479 {
479- return end ();
480+ return xend ();
480481 }
481482
482483 template <class T , int ExtraFlags>
483484 template <class S >
484485 inline auto pyarray<T, ExtraFlags>::xbegin(const S& shape) -> xiterator<stepper, S>
485486 {
486- return xiterator<stepper, S>(stepper_begin (shape), shape);
487+ return xiterator<stepper, S>(stepper_begin (shape), & shape);
487488 }
488489
489490 template <class T , int ExtraFlags>
490491 template <class S >
491492 inline auto pyarray<T, ExtraFlags>::xend(const S& shape) -> xiterator<stepper, S>
492493 {
493- return xiterator<stepper, S>(stepper_end (shape), shape);
494+ return xiterator<stepper, S>(stepper_end (shape), & shape);
494495 }
495496
496497 template <class T , int ExtraFlags>
497498 template <class S >
498499 inline auto pyarray<T, ExtraFlags>::xbegin(const S& shape) const -> xiterator<const_stepper, S>
499500 {
500- return xiterator<const_stepper, S>(stepper_begin (shape), shape);
501+ return xiterator<const_stepper, S>(stepper_begin (shape), & shape);
501502 }
502503
503504 template <class T , int ExtraFlags>
504505 template <class S >
505506 inline auto pyarray<T, ExtraFlags>::xend(const S& shape) const -> xiterator<const_stepper, S>
506507 {
507- return xiterator<const_stepper, S>(stepper_end (shape), shape);
508+ return xiterator<const_stepper, S>(stepper_end (shape), & shape);
508509 }
509510
510511 template <class T , int ExtraFlags>
@@ -526,67 +527,67 @@ namespace xt
526527 inline auto pyarray<T, ExtraFlags>::stepper_begin(const S& shape) -> stepper
527528 {
528529 size_type offset = shape.size () - dimension ();
529- return stepper (this , storage_begin (), offset);
530+ return stepper (this , begin (), offset);
530531 }
531532
532533 template <class T , int ExtraFlags>
533534 template <class S >
534535 inline auto pyarray<T, ExtraFlags>::stepper_end(const S& shape) -> stepper
535536 {
536537 size_type offset = shape.size () - dimension ();
537- return stepper (this , storage_end (), offset);
538+ return stepper (this , end (), offset);
538539 }
539540
540541 template <class T , int ExtraFlags>
541542 template <class S >
542543 inline auto pyarray<T, ExtraFlags>::stepper_begin(const S& shape) const -> const_stepper
543544 {
544545 size_type offset = shape.size () - dimension ();
545- return const_stepper (this , storage_begin (), offset);
546+ return const_stepper (this , begin (), offset);
546547 }
547548
548549 template <class T , int ExtraFlags>
549550 template <class S >
550551 inline auto pyarray<T, ExtraFlags>::stepper_end(const S& shape) const -> const_stepper
551552 {
552553 size_type offset = shape.size () - dimension ();
553- return const_stepper (this , storage_end (), offset);
554+ return const_stepper (this , end (), offset);
554555 }
555556
556557 template <class T , int ExtraFlags>
557- inline auto pyarray<T, ExtraFlags>::storage_begin () -> storage_iterator
558+ inline auto pyarray<T, ExtraFlags>::begin () -> iterator
558559 {
559- return reinterpret_cast <storage_iterator >(pybind11::detail::array_proxy (m_ptr)->data );
560+ return reinterpret_cast <iterator >(pybind11::detail::array_proxy (m_ptr)->data );
560561 }
561562
562563 template <class T , int ExtraFlags>
563- inline auto pyarray<T, ExtraFlags>::storage_end () -> storage_iterator
564+ inline auto pyarray<T, ExtraFlags>::end () -> iterator
564565 {
565- return storage_begin () + pybind_array::size ();
566+ return begin () + pybind_array::size ();
566567 }
567568
568569 template <class T , int ExtraFlags>
569- inline auto pyarray<T, ExtraFlags>::storage_begin () const -> const_storage_iterator
570+ inline auto pyarray<T, ExtraFlags>::begin () const -> const_iterator
570571 {
571- return reinterpret_cast <const_storage_iterator >(pybind11::detail::array_proxy (m_ptr)->data );
572+ return reinterpret_cast <const_iterator >(pybind11::detail::array_proxy (m_ptr)->data );
572573 }
573574
574575 template <class T , int ExtraFlags>
575- inline auto pyarray<T, ExtraFlags>::storage_end () const -> const_storage_iterator
576+ inline auto pyarray<T, ExtraFlags>::end () const -> const_iterator
576577 {
577- return storage_begin () + pybind_array::size ();
578+ return begin () + pybind_array::size ();
578579 }
579580
580581 template <class T , int ExtraFlags>
581- inline auto pyarray<T, ExtraFlags>::storage_cbegin () const -> const_storage_iterator
582+ inline auto pyarray<T, ExtraFlags>::cbegin () const -> const_iterator
582583 {
583- return reinterpret_cast <const_storage_iterator >(pybind11::detail::array_proxy (m_ptr)->data );
584+ return reinterpret_cast <const_iterator >(pybind11::detail::array_proxy (m_ptr)->data );
584585 }
585586
586587 template <class T , int ExtraFlags>
587- inline auto pyarray<T, ExtraFlags>::storage_cend () const -> const_storage_iterator
588+ inline auto pyarray<T, ExtraFlags>::cend () const -> const_iterator
588589 {
589- return storage_begin () + pybind_array::size ();
590+ return begin () + pybind_array::size ();
590591 }
591592
592593 template <class T , int ExtraFlags>
0 commit comments