Original Post
When using STL algorithms, I often find myself typing stuff like
accumulate(a.begin(), a.end(), 0);
for_each(b.begin(), b.end(), foo);
remove_if(c.begin(), c.end(), bar);
Today I thought to myself: why not use the preprocessor to make things clearer?
#define ALL(x) x.begin(), x.end()
accumulate(ALL(a), 0);
for_each(ALL(b), foo);
remove_if(ALL(c), bar);
As long as x is just a variable, I don't see any problems with it. Is this a reasonable use of the evil preprocessor? Maybe there's even a real solution I don't know about? Discuss!