There is a good article about BOOST_FOREACH by Eric Niebler on The C++ Source.

It contains some interesting trickery involving the ternary conditional operator (?:).