I only just recently discovered that Visual C++ 2008 (and perhaps earlier versions as well?) supports for each
syntax on stl lists et al to facilitate iteration.
For example:
list<Object> myList;
for each (Object o in myList)
{
o.foo();
}
I was very happy to discover it, but I'm concerned about portability for the dreaded day when someone decides I need to be able to compile my code in say, gcc or some other compiler. Is this syntax widely supported and can I use it without worrying about portability issues?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…