
3 Jan
2008
3 Jan
'08
6:11 p.m.
Mathias Gaunard wrote:
Neal Becker wrote:
The common idiom is:
for (; i != boost::end (vector); ++i) ...
The compiler had damn well better realize that boost::end is a constant function that can be lifted from the loop, or performance can be severely impacted.
boost::end is not a constant function, because the vector can change.
However, boost::end(vector) is the same as vector._M_begin + vector._M_size (implementation specific names) I wouldn't say one addition can severely impact performance.
I believe a lot of optimizers can optimize out that addition if the vector wasn't changed anyway.
Sorry I was not clear. I did not mean std::vector, I meant a generic vector concept.