Optimize InputIterator dereference without making a copy if possible?
问题 I have a legacy code in which the interface is defined for pointer only and I am trying to adapt some functions to take iterators. In the answers to this question Address of a dereferenced InputIterator? The case of istream_iterator it was noted that std::istream_iterators are InputIterator . However they are special among InputIterator s, because their dereference is guarantied to generate a language reference T const& . The code for a general input iterator would look like this, notice that