C++ Iterator dereference and prefix increment/decrement style? Is *--Iter ok style wise?

后端 未结 4 1613
[愿得一人]
[愿得一人] 2021-01-22 22:56

In coding with C++ iterators if you wanted to get the previous value to what an iterator points to would you write:

*--Iter

or would you think

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-22 23:33

    It doesn't matter as far as program correctness is concerned. But I always express this as *(--Iter) because this is more self-documenting and easier to understand to human beings than *--Iter.

提交回复
热议问题