Skip to content

Commit 0f06096

Browse files
authored
Fix reverse iterators xstorage (#2908)
# Checklist - [ ] The title and commit message(s) are descriptive. - [ ] Small commits made to fix your PR have been squashed to avoid history pollution. - [ ] Tests have been added for new features or bug fixes. - [ ] API of new functions and classes are documented. # Description <!--- Give any relevant description here. If your PR fixes an issue, please include "Fixes #ISSUE" (substituting the relevant issue ID). --> --------- Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
1 parent a497243 commit 0f06096

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

include/xtensor/containers/xstorage.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,16 @@ namespace xt
16401640
return m_array.cend();
16411641
}
16421642

1643+
auto crbegin() const
1644+
{
1645+
return m_array.crbegin();
1646+
}
1647+
1648+
auto crend() const
1649+
{
1650+
return m_array.crend();
1651+
}
1652+
16431653
constexpr std::size_t operator[](std::size_t idx) const
16441654
{
16451655
return m_array[idx];

test/test_xfixed.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "xtensor/core/xnoalias.hpp"
2323
#include "xtensor/io/xio.hpp"
2424
#include "xtensor/misc/xmanipulation.hpp"
25+
#include "xtensor/views/xview.hpp"
2526

2627
#include "test_common_macros.hpp"
2728

@@ -306,6 +307,13 @@ namespace xt
306307
using tiny_tensor = xtensor_fixed<double, xshape<2>, layout_type::row_major, false>;
307308
EXPECT_GT(sizeof(fixed_tensor), sizeof(tiny_tensor));
308309
}
310+
311+
TEST(xtensor_fixed, iterators)
312+
{
313+
auto arr = xt::xtensor<double, 1>({5, 5, 5, 5, 5});
314+
auto fixed_arr = xt::xtensor_fixed<double, xt::xshape<3>>{1, 2, 3};
315+
xt::view(arr, xt::range(0, 3)) = fixed_arr + 1;
316+
}
309317
}
310318

311319
#endif

0 commit comments

Comments
 (0)