ForEach中的最后一个元素 [英] Last Element in ForEach

查看:206
本文介绍了ForEach中的最后一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++有一个预建的方法来识别你在你的foreach循环中的哪个元素,或者如果有一种方法来识别你是否在你的最后一个元素?或者,我必须用计数器手动做?

Does C++ have a pre-built method to identify which element you are on in your foreach loop, or if there is a way to identify if you are on your last element? Or do I have to do it manually with a counter?

推荐答案

不,没有这样的内置方式。一般来说也不能有迭代器,因为迭代器不需要知道他们几乎在结束。

No, there is no such built-in way. Nor could there be for iterators in general, because iterators aren't required to know that they are "almost" at the end.

这篇关于ForEach中的最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆