PDA

View Full Version : Why is QVector's iterator using prefixed increase and postfix decrease internally?



Kampfgnom
9th November 2015, 10:04
Hi everyone,

I am currently implementing an iterator for an internal data structure and had a look at how QVector implements its iterator. I don't understand why the QTypedArrayData::iterator implements its ++ and -- operators like:



T *i;
inline iterator &operator++() { ++i; return *this; }
inline iterator &operator--() { i--; return *this; }


What I don't understand is the discrepancy between the two: Why does it use a postfix decrement operator?

Thanks for any clarification!