From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-08-15 03:04:18
Here is ptr<> nearly fully portable:
- 5.7.6 footer 21:
"Another way to approach pointer arithmetic is first to convert the
pointer(s) to character pointer(s): In this scheme the integral value of
the expression added to or subtracted from the converted pointer is first
multiplied by the size of the object originally pointed to, and the
resulting pointer is converted back to the original type. For pointer
subtraction, the result of the difference between the character pointers is
similarly divided by the size of the object originally pointed to."
therefore class offset is perfectly legal.
- Non referenced ptr_base<T, __false_type>::m_ptr will temporarily contain
an undefined pointer since its address is wrong. It could simply be
considered as a void * but kept this way to preserve clean code.
- What remains to do is to ensure alignment of the object in question. I do
not know the best solution yet but it would be great to determine the
greatest implementation-dependant word boundary. In general it shouldn't be
greater than 32 or 64 bits.
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