Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-08-07 16:02:36

"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
> > More comments:
> >
> > Your code results in undefined behaviour, since it accesses vector
> > elements that have not been constructed. Even though the data type
> > is POD, accessing vector[i] where i >= vector.size() is not legal C++.
> Why is it public then? There's a flaw in their standards therefore.

If I use resize() instead, will it shrink down the allocated block (exactly
what I don't want) if the new size is smaller than the previous one?


> > The use of len<> also seems suspect (by which I mean redundant and
> > unnecessary). It seems that operator+ and operator- should be friend
> > functions of offset. And the implementation type of offset should
> > probably be ptrdiff_t. I'm sure there's more oddities lurking, but that
> > should be enough to keep you busy for a while. ;)
> >
> > Dave
> len<>() is usefull to implicitly generate offsets, but I'll look at
> ptrdiff_t.

ptrdiff_t is a macro, is therefore not flexible. offset was created to
simplify pointer arithmetics and to remove some implicit headaches...

Philippe A. Bouchard

Boost list run by bdawes at, gregod at, cpdaniel at, john at