Results 1 to 1 of 1

Thread: Why is QVector's iterator using prefixed increase and postfix decrease internally?

  1. #1
    Join Date
    Dec 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Why is QVector's iterator using prefixed increase and postfix decrease internally?

    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:

    Qt Code:
    1. T *i;
    2. inline iterator &operator++() { ++i; return *this; }
    3. inline iterator &operator--() { i--; return *this; }
    To copy to clipboard, switch view to plain text mode 

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

    Thanks for any clarification!
    Last edited by Kampfgnom; 9th November 2015 at 10:58.

Similar Threads

  1. Prefixed for life?
    By qtoptus in forum Qt Programming
    Replies: 2
    Last Post: 16th April 2014, 18:32
  2. QTableView / QAbstractItemView Dragging rows internally
    By schapman1974 in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2013, 15:44
  3. Replies: 5
    Last Post: 2nd September 2011, 23:11
  4. [SOLVED] QVector iterator seg fault using .begin/.end
    By pheonixstorm in forum Qt Programming
    Replies: 2
    Last Post: 9th January 2011, 07:43
  5. How to increase/decrease brightness/sharpness
    By rishiraj in forum Newbie
    Replies: 2
    Last Post: 21st January 2009, 06:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.