The SmartQuadtree<T>::iterator::operator++() works ok for template T = shared_ptr<U> but not in the default case. Indeed, the pointer to (*it) is to refer trashed data (see erase at the end of the block) after a copy of it is included in a different part of the quadtree.
Consider changing the signature of SmartQuadtree<T>::insert(T) to return the proper pointer.
The
SmartQuadtree<T>::iterator::operator++()
works ok fortemplate T = shared_ptr<U>
but not in the default case. Indeed, the pointer to(*it)
is to refer trashed data (seeerase
at the end of the block) after a copy of it is included in a different part of the quadtree.SmartQuadtree<T>::insert(T)
to return the proper pointer.ancestor->where