开发者

Returning an iterator to an element in STL Container

how would you check if the iterator that was returned by the function points to something in container cl开发者_开发技巧ass?


Iterators are passed around as [begin,end) pairs, with the end value signifying "not found" or other forms of the empty sequence. Return that from your function, or return a pair<bool,iterator> (or similar).


You can't. Make sure you return a valid iterator.

Well I suppose you could by iterating through the container and checking to see if the iterators are equal. But that would be horrid.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜