Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2004-05-08 05:06:21

Rainer Deyke wrote:

> David Abrahams wrote:
>>Err, this could only work if you were willing to pass the loop block
>>to the macro. Might be worth the pain, though (?)
> If you are willing to pass the loop body to the macro, you don't need the
> inner for loop at all.

That's all true, but IMO it isn't worth the pain. I'm OK with
BOOST_FOREAH being 4% slower than a hand-coded loop on average (until
compilers get better flow control analysis). In exchange, users get a
nice, first-class feel. It behaves like a new keyword instead of a
macro, which is intended.

It's certainly a judgement call, but the perf/usability trade-off was a
conscious one. The tiny perf hit seems a small price.

Eric Niebler
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at