Boost logo

Boost :

From: kris.thielemans_at_[hidden]
Date: 2000-12-07 08:24:10


--- In boost_at_[hidden], Kevlin Henney <kevlin_at_c...> wrote:
> In message <90meim+dsel_at_e...>, gbavestrelli_at_y... writes
> >--- In boost_at_[hidden], Kevlin Henney <kevlin_at_c...> wrote:
> >> In message <003901c05fa0$23f097b0$460a10ac_at_r...>, Kris Thielemans
> >> <kris.thielemans_at_i...> writes
> >> >> >> >- I allow indices with non-zero offset
> >> >>
> >> >> For any particular reason?
> >> >
> >> >just to have more natural index values in our application.
> >
> >This is very easy to add to the array, and does not complicate the
> >interface much. But I preferred to leave it out, in line with
> >standard C arrays and STL vectors. How do others feel about this?
>
> I prefer to leave it out. It seems like unnecessary featurism. TBH
its
> absence has never been a show stopper in using arrays: quite the
> opposite, in fact, as the semantics are clearer. My view is that if
you
> have a special mapping, it is the responsibility of the higher-level
> class using it to deal with that. In other words, layering rather
than
> over-parameterisation.
>

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.

Kris


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