
2 May
2005
2 May
'05
6:56 p.m.
Stefan Strasser wrote:
Dave Harris schrieb:
For example, from looking at the implementation it seems that the macro caches the end() value in a variable called _foreach_end.
it is cached, but why? end is end and stays end, unless it is invalidated.
Performance. Even when writing loops by hand, it's a good idea to save the result of .end() in a local to avoid repeated function calls that are not necessary. It's called "hoisting". It's one of the side-benefits of using FOREACH and std:: algorithms. -- Eric Niebler Boost Consulting www.boost-consulting.com