I studied the weakly_incrementable
concept recently and I am wondering what the post-increment operator is good for, given that the concept does not define any requirements for the result of the operation.
Is it actually okay to return void
for operator++(int)
?
void operator++(int) { ++(*this); }
It seems in line with the other requirements of the concept (like that it does not have to be copyable) and also with the fact that the incrementable
concept introduces requirements that make i++
useful, but in that case I am wondering why i++
is defined by the concept at all. After all, when you require something to implement the weakly_incrementable
concept, you can always use ++i
instead of i++
because
- you can't rely on
i++
having any useful properties, apart from those already provided by++i
but i++
may be more inefficient (when it creates a copy of the iterator, for example).