STL iterator: “dereferencing” iterator to a temporary. Is it possible?
问题 I'm writing a 3D grid for my scientific software and I need to iterate through the nodes of the grid to get their coordinates. Instead of holding each node object in the container I'd rather like to just calculate the coordinates on the fly while iterating. The problem is that stl::iterator requires to return reference to a value as a result of operator*() , or pointer for operator->() . Some of the code below: class spGridIterator { public: typedef forward_iterator_tag iterator_category;