Boost logo

Boost :

Subject: Re: [boost] boost.foreach overhead
From: Christopher Jefferson (chris_at_[hidden])
Date: 2010-10-17 17:39:23


On 17 Oct 2010, at 22:01, Scott McMurray wrote:

> On Sun, Oct 17, 2010 at 10:12, Christopher Lux <christopherlux_at_[hidden]> wrote:
>> On 10/9/2010 John Carmack of id Software wrote on his Twitter account: “@ID_AA_Carmack: It took 69 single steps to get past a BOOST_FOREACH() statement. Madness.”
>>
>> This made me think again about the overhead introduced with boost foreach. Is the overhead really this large as he makes it sound? Are there heuristics to when to use foreach according to the expected iteration counts?
>>
>
> If he says "steps", I figure he must mean in a debugger. Since
> performance in generic C++ code relies heavily on inlining, I'm not
> surprised it's high as the number is mostly meaningless.

Mostly meaningless? Having to step through 69 steps to go through each stage of a for loop makes debugging almost impossible.

It is for precisely this reason that most projects I work on forbid BOOST_FOREACH, and a similar preprocessing madness. They just make debugging, and tracking down compile-time errors, too hard.

Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk