diff --git a/src/OpenMesh/Core/Mesh/Handles.hh b/src/OpenMesh/Core/Mesh/Handles.hh index 24eb3264..89dd9d27 100644 --- a/src/OpenMesh/Core/Mesh/Handles.hh +++ b/src/OpenMesh/Core/Mesh/Handles.hh @@ -98,6 +98,8 @@ public: void __increment() { ++idx_; } void __decrement() { --idx_; } + void __increment(int amount) { idx_ += amount; } + void __decrement(int amount) { idx_ += amount; } private: diff --git a/src/OpenMesh/Core/Mesh/IteratorsT.hh b/src/OpenMesh/Core/Mesh/IteratorsT.hh index 8d2e9dcb..d12e5eb0 100644 --- a/src/OpenMesh/Core/Mesh/IteratorsT.hh +++ b/src/OpenMesh/Core/Mesh/IteratorsT.hh @@ -170,6 +170,37 @@ class GenericIteratorT { return cpy; } +#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY) + template + auto operator+=(int amount) -> + typename std::enable_if< + sizeof(decltype(std::declval().__increment(amount))) >= 0, + GenericIteratorT&>::type { + static_assert(std::is_same::value, + "Template parameter must not deviate from default."); + if (skip_bits_) + throw std::logic_error("Skipping iterators do not support " + "random access."); + hnd_.__increment(amount); + return *this; + } + + template + auto operator+(int rhs) -> + typename std::enable_if< + sizeof(decltype(std::declval().__increment(rhs), void (), int {})) >= 0, + GenericIteratorT>::type { + static_assert(std::is_same::value, + "Template parameter must not deviate from default."); + if (skip_bits_) + throw std::logic_error("Skipping iterators do not support " + "random access."); + GenericIteratorT result = *this; + result.hnd_.__increment(rhs); + return result; + } +#endif + /// Standard pre-decrement operator GenericIteratorT& operator--() { hnd_.__decrement();