Iterator error value
whats a value that is generally used as an error value besides <cont开发者_运维百科ainer>.end()
? im doing a simple linear search through a std::list<int>
and i want a way to know that the search did not turn up a place in the list
All of the standard C++ classes return <container>.end()
when a search result fails since end()
doesn't actually point to an element in the container (it points "past-the-end" of the container). I don't see a reason why another type would be necessary.
i want a way to know that the search did not turn up a place in the list
std::find is helpful for the task.
精彩评论