Pattern: Use of postfix increment/decrement
Issue: -
Use prefix form (++i
) of the increment and decrement operators with iterators and other template objects. For example following function:
void increment_counter(int* count) {
*count++;
}
is invalid, because it effectively does count++, moving pointer, and should be replaced with ++*count, (*count)++
or *count += 1
.