|
Boost : |
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-01-03 12:35:51
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk