On Fri, May 9, 2014 at 6:37 AM, Nicky D. <sl.nicky...@googlemail.com> wrote:

>
>> > I notice "operator[](i)" is used in the interesting,
>>
>> With std::vector, you could also use array.at(i), which is equivalent.
>
>
> vector::at will do a runtime check if the index is out of bounds, in that
> case it throws
> an exception.
>
> vector::operator[] will not do this check, causing undefined behavior when
> accessing
> elements out of bounds.
>

Slight tweak: [] on out of bounds members is undefined, but specific
implementations may still check.

Most (maybe even all) STL implementations support bounds checking with a
compile flag. If anyone's eager to experiment, it would be nice to add that
to the debug build flags and see if debugging performance is still
tolerable on all platforms.

-- 
*Brian McGroarty *| Application Security, Platform Engineering

*Linden Lab* | Makers of Shared Creative Spaces <http://lindenlab.com/>
_______________________________________________
Policies and (un)subscribe information available here:
http://wiki.secondlife.com/wiki/OpenSource-Dev
Please read the policies before posting to keep unmoderated posting privileges

Reply via email to