Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-08-07 12:21:50


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

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


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