开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜