Here is some C++ code I\'m playing around with:
#include
#include
#define IN ,
#define FOREACH(x,y) for(unsigned int i=0;i&l
The compiler doesn't expand the IN macro before it reads the arguments to FOREACH. In fact, I think this is intentional (so that you can pass a comma to a macro).
Unfortunately, you'll have to use FOREACH(int item, ints).
You could also #define IN (make it nothing) and then use FOREACH(int item, IN ints), which is not quite as nice, but is acceptable.
That said, you may just want to use STL or Boost for foreach, unless you specifically want to create your own.