Closed rgcv closed 4 years ago
I tried applying the following patch and it seems to be working.
diff --git a/include/jlcxx/array.hpp b/include/jlcxx/array.hpp
index 29b59ed..d3d9922 100644
--- a/include/jlcxx/array.hpp
+++ b/include/jlcxx/array.hpp
@@ -54,12 +54,26 @@ public:
return *this;
}
+ array_iterator_base<PointedT, CppT> operator++(int)
+ {
+ auto result(*this);
+ ++(*this);
+ return result;
+ }
+
array_iterator_base<PointedT, CppT>& operator--()
{
--m_ptr;
return *this;
}
+ array_iterator_base<PointedT, CppT> operator--(int)
+ {
+ auto result(*this);
+ --(*this);
+ return result;
+ }
+
array_iterator_base<PointedT, CppT>& operator+=(std::ptrdiff_t n)
{
m_ptr += n;
Feel free to use this or modify it at will :) I can also submit a PR if you prefer.
Assuming this is one of the insufficiencies of
jlcxx::ArrayRef
since it isn't strictly compatible with a typical STL container, or at least its iteration interface isn't.I found an issue using
array_iterator_base
when presented with syntax such like*begin++
, faced with the errorno 'operator++'(int) declared for postfix '++'
.Currently, to circumvent this issue, I have to hack around it using a
std::vector
. Here's a hypothetical example of a method creation in modulemod
:It's an easy hack, but seems unnecessary to introduce the additional complexity of rebuilding an entire STL container for the purposes of passing it immediately through to another function.