|
Boost : |
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2008-01-03 13:11:31
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk