
Erik wrote:
Unfortunately it does not look so good for BOOST_FOREACH after this modification. It will increase to 24 instructions, while the handcoded is still only 21. I created a script (attached) to test the examples systematically with different compiler versions and optimization levels.
Forgive me if this was answered in an earlier post, but how complex is the loop body, including the complexity of any functions it calls? If the total is more than a few lines long, contains several function calls, or performs even moderatley complex arithmetic, then three extra instructions in the for loop's header may not matter. Do you have access to a profiler? They often surprise me when I look at a report showing what parts of my program are actually using the most processor time (or wall clock time, if that is more important to you).