Fix crash when changing the number of points
std::rotate
accepts an "end" iterator that points one after the last
item. In plain C, it's possible to create a "one past end" pointer by
using the following idiom: &arr[size]
, which is equivalent to arr + size
.
No actual pointer dereference happens in this case. In C++, vector[index]
always causes a vector.operator[](index)
invocation; it is undefined
behavior to use this method with out-of-bounds indexes. Therefore, this
idiom cannot be used in C++ to get a "one past end" iterator. Instead,
C++ provides .begin()
and .end()
methods. Use those instead.
- Fixes #197 (closed)
- Fixes #181 (closed)