Vector iterator
Oct 31, 2017 at 7:13pm UTC
Hi guys,
I have a question about vector iterators. Maybe it's should be in a beginner thread, if yes I'm so sorry about that. I looking at the std::find_if func template here on cplusplus site
http://www.cplusplus.com/reference/algorithm/find_if/
.. in example when you want to print a iterator value you have to dereference iterator with
(they use
see in the above link example)
My code is below, and I don't understand why I don't have to dereference my iterator to get its value. It's enough to write
to get the value.
1 2 3 4 5
std::vector<std::pair<std::wstring, std::wstring>>::iterator it = std::find_if(lFileList.begin(), lFileList.end(), [&](std::pair<std::wstring, std::wstring> const & pair){
return pair.first == selDoc;
});
std::wstring ACSLiink = GetDocumentACSRequestTask(it->second); // func parameter is a std::wstring
Please, Can you explain it to me. I always think about the iterator as a pointer. If you can suggest me a good article about it I would appreciate.
Last edited on Oct 31, 2017 at 7:18pm UTC
Oct 31, 2017 at 7:23pm UTC
it->second
is equivalent to (*it).second
.
Oct 31, 2017 at 7:50pm UTC
OMG .. shame on me.. ty for this quick answer
Topic archived. No new replies allowed.