Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-08-07 12:51:38


> 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.

> Anyway, I don't think you need the vector anyway, since a new s_id
> is created for each type on which you instantiate ptr<>. Furthermore,
> it is not at all clear how get_type_id() is supposed to work, but it
> seems almost certain to me that it does not work the way you intend
> it to, or is non-portable, or results in undefined behaviour (or possibly
> some union of the above ;).

The table is needed because it maps offsets associated with type T and all
the object this type could point to.

> 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.

Philippe A. Bouchard


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