Ugly? Andrew Koenig and Barbara Moo show a similar construct in their book "Accelerated C++". ;)
A little off topic, but this is on page 19, before for loops are introduced. If you look ahead to page 27 (2.5.2) that example is redone with a for loop.
Chris.