Boost logo

Boost :

From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2008-06-05 15:40:08

Phil wrote:
>Last but not least the library now takes advantage of the
>fast_pool_allocator for objects such as "struct set" and
>"numeric::interval<int>". FYI I am using "numeric::interval<int>"
>of "numeric::interval<void *>" because of a compilation failure with
>latter. I am casting the pointers to an "int" meanwhile because there
is >no
>lost of information by doing so according to the standards.

void * p = ordered_malloc(s);
get()->push_back(numeric::interval<int>((int) p, int((char *)(p) + s)));

I forgot to mention that casting the pointer to signed integer will
cause problems even if they happen to be the same bit width. This is
because pointer values with a 1 in the msb will cast to negative integer
values, which will cause the order of p and p+s to become inverted,
leading to an error condition in numeric::interval, which will result in
a null interval, according to interval's documentation. That would be
difficult to debug.


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