Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-12-07 08:48:07


----- Original Message -----
From: <kris.thielemans_at_[hidden]>
>
> I'd agree, if there is a way to let the higher-level class do this
> without performance penalty, and I don't think so. The higher level
> class would have to subtract all the offsets all the time, before
> passing it to Array::operator[]. If you build it in in Array, and you
> store pointers towards to 0 index, you don't have any performance
> penalty.

These kinds of optimizations are built into most modern compilers (I think
it's called "hoisting", but I don't keep track of the names of these things
so I can't be sure). Also, I worry the proposed approach leads to undefined
behavior by forming a pointer outside the range [first-element,
one-past-the-last-element] of an array.

-Dave


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