Boost logo

Boost :

Subject: Re: [boost] Geometry and spatial indexes, my opinion
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-10-13 12:12:20


Mathias Gaunard wrote:
> Brandon Kohn wote:
>
>> If so, how does direct iteration compare with index
>> operator accesses? I've noticed in my own tests on measuring
>> std::vector accesses that iteration is significantly faster than
>> operator [ ] when you are iterating over the container (presumably due
>> to bounds checking).
>
> operator[] doesn't do bounds checking, unless you have the debug/secure
> mode of your standard library enabled (which is on by default on MSVC).
>
> While access by index is theoretically slower than pointer increments,
> I'm pretty sure any compiler optimizes the former to the latter.
>

At least with MSVC9 they aren't exactly equivalent.

http://lists.boost.org/Archives/boost/2008/09/142657.php

-- 
Michael Marcin

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk