On Monday, 23 March 2015 at 12:10:32 UTC, Kagamin wrote:
Well, things like std::string are not cooperative in this
regard. Though, it's copied only to be instantly destructed,
theoretically it should be elided if the involved constructors
are annotated with sufficient purity or complementary operators.
That's why using preincrementation is the preferred default - you
simply can't know predict what the user's type will do. And sure,
maybe the compiler should optimize it away in this case, but as
you can see, the pragmatic solution is to simply avoid this
problem entirely.
Also the iterator pretends to be copyable, but it can't resume
from the point where it was copied, can it?
Depends on the iterator type, in this case: no, I don't believe
that it can be resumed.