jeudi 28 décembre 2017

Do postfix operators return lvalue?

Isn't the foll code given in C++ Primer incorrect ?

ostream_iterator<int> out_iter(cout, " ");
for (auto e : vec)
    *out_iter++ = e;  // the assignment writes this element to cout
cout << endl;

The postfix operator returns the old value, not a reference then how can it be made to act as an lvalue ?

Please correct if I am wrong

Aucun commentaire:

Enregistrer un commentaire