Skip to content

Commit 60ce400

Browse files
committed
Added required types to xchunk_iterator
1 parent 2b9c2b0 commit 60ce400

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

include/xtensor/xchunked_assign.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ namespace xt
110110
template <class A>
111111
struct xchunk_iterator_array
112112
{
113+
using reference = decltype(*(std::declval<A>().chunks().begin()));
114+
113115
inline decltype(auto) get_chunk(A& arr, typename A::size_type i, const xstrided_slice_vector&) const
114116
{
115117
return *(arr.chunks().begin() + i);
@@ -119,6 +121,8 @@ namespace xt
119121
template <class V>
120122
struct xchunk_iterator_view
121123
{
124+
using reference = decltype(xt::strided_view(std::declval<V>().expression(), std::declval<xstrided_slice_vector>()));
125+
122126
inline auto get_chunk(V& view, typename V::size_type, const xstrided_slice_vector& sv) const
123127
{
124128
return xt::strided_view(view.expression(), sv);
@@ -148,6 +152,13 @@ namespace xt
148152
using shape_type = typename E::shape_type;
149153
using slice_vector = xstrided_slice_vector;
150154

155+
using reference = typename base_type::reference;
156+
using value_type = std::remove_reference_t<reference>;
157+
using pointer = value_type*;
158+
using difference_type = typename E::difference_type;
159+
using iterator_category = std::forward_iterator_tag;
160+
161+
151162
xchunk_iterator() = default;
152163
xchunk_iterator(E& chunked_expression,
153164
shape_type&& chunk_index,

include/xtensor/xchunked_view.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ namespace xt
3333

3434
using self_type = xchunked_view<E>;
3535
using expression_type = std::decay_t<E>;
36-
using size_type = size_t;
36+
using value_type = typename expression_type::value_type;
37+
using reference = typename expression_type::reference;
38+
using const_reference = typename expression_type::const_reference;
39+
using pointer = typename expression_type::pointer;
40+
using const_pointer = typename expression_type::const_pointer;
41+
using size_type = typename expression_type::size_type;
42+
using difference_type = typename expression_type::difference_type;
3743
using shape_type = svector<size_type>;
3844
using chunk_iterator = xchunk_iterator<self_type>;
3945
using const_chunk_iterator = xchunk_iterator<const self_type>;

test/test_xchunked_array.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,9 @@ namespace xt
148148
}
149149
}
150150
}
151+
152+
it = a.chunk_begin();
153+
std::advance(it, 2);
154+
EXPECT_EQ(*((*it).begin()), a(0, 0, 4));
151155
}
152156
}

0 commit comments

Comments
 (0)