
On 02/12/09 16:19, Larry Evans wrote: [snip]
I guess the compiler can do some sort of analysis to figure which templates really need to be instantiated and which don't. Maybe when instantiating some template, the compiler looks at which other templates are needed by the methods in that template (wait, there were not methods in while_, but maybe in the IfOps arg to while_) and then instantiates only those, but other compilers don't bother with that and instantiate templates even though they're not used.
One example of an unneeded instantiations are those for some of the and_ifops::else_. The profile shows that was instantiated 4 times: and_seq_while.cpp:106 4 134 when only the last one is really needed. Which leads to the obvious (at least now) optimization of just making State as the last element in the eval_if super of while_. So, maybe the gcc you're using does this sort of optimization for the find_if but not for the while_ implementation.