W
wenmang
Hi, all:
I am reading the book "The C++ Stadnard Library" by Josuttis. I have
trouble to understand
operations for the insert iterator(page 272).
++itr, *itr and itr++ are defined as no-op, and "itr = value"(supported
expression *itr = value") is
defined as "inserts value"
The example given in the book is:
vector<int> coll;
back_insert_iterator<vector<int> > itr(coll);
....
*itr = 1;
itr++;
*itr = 2;
*itr++;
....
Here is my question, if "itr++" defined as no-op what is the purpose of
using itr++ in the above
example? why could we use just:
*itr = 1;
*itr = 2;
instead?
Thanks.
I am reading the book "The C++ Stadnard Library" by Josuttis. I have
trouble to understand
operations for the insert iterator(page 272).
++itr, *itr and itr++ are defined as no-op, and "itr = value"(supported
expression *itr = value") is
defined as "inserts value"
The example given in the book is:
vector<int> coll;
back_insert_iterator<vector<int> > itr(coll);
....
*itr = 1;
itr++;
*itr = 2;
*itr++;
....
Here is my question, if "itr++" defined as no-op what is the purpose of
using itr++ in the above
example? why could we use just:
*itr = 1;
*itr = 2;
instead?
Thanks.