开发者

Iterator error value

开发者 https://www.devze.com 2023-02-19 07:25 出处:网络
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 s

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

精彩评论

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