Quote:Original post by SpreeTree
I don't know if "you can save a lot of time in the future when you start trying to treat an iterator as you would a pointer" was clear enough, but I meant you can save yourself time by knowing exactly why treating an iterator like a pointer causes errors, rather then trying to use it as one and not knowing why it doesn't work.
Considering that the statement has nothing to do with what you say it means, then it probably isn't clear enough. Re-read that sentence a few times. You said that using treating an iterator like a pointer saves time, which, as I said, contradicts your argument. It says nothing about understanding why treating an iterator as a pointer would cause errors. It instead says that treating an iterator as a pointer is beneficial.
Quote:Would I dereference a vector<MyObject**>::iterator. To right I would. I'd much rather use the basic type (MyObject**) as I assume I know what that is, know how it works and understand the context in which I am using it.
Not what I asked, especially given that using -> on a vector<MyObject **>::iterator would be invalid. I asked if you would always dereference normal pointers, since that makes your code that uses double pointers the same as the code that uses normal pointers. Since you think that the existence of vector<MyObject*>::iterator justifies always dereferencing vector<MyObject>::iterators before using them, applying the same logic to pointers means that you would never use -> on a MyObject * since you can't use -> on a MyObject **.
Quote:
Personally I would call do_something(*(my_vector.begin()+7)) and pass it by reference for two reasons
But you're still doing random access iterator arithmetic on the iterator, which is something you can do on normal pointers, which by your logic makes you think of iterators like pointers, so you should never do.
Quote:But by being able to use iterators as pointers (by being able to use operator->),
Using -> isn't using an iterator as a pointer, it's using an iterator as an iterator.
Unless you want to say that any valid operation on an iterator that is also a valid operation on a pointer is using an iterator like a pointer. In which case there is absolutely no operation on an iterator that isn't also using an iterator as a pointer. Even dereferencing an iterator like you suggest would be using an iterator like a pointer.
Quote:You are talking about the implementation details of the STL,
And where do you see any implementation details in my posts? I'm talking about the use of STL, and the inconsistency of your arguments for not using iterator functionality. A brief perusal of this thread shows the only implementation detail mentioned would actually have been brought up by you, with your alleged STL implementation that doesn't support -> on container iterators.