|
Boost : |
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2008-06-05 13:39:39
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>"
instead
>of "numeric::interval<void *>" because of a compilation failure with
the
>latter. I am casting the pointers to an "int" meanwhile because there
is >no
>lost of information by doing so according to the standards.
Pointers are certainly not guaranteed to be the same width as int by the
standard. The standard doesn't get to say anything about the size of
the built-in types, which may differ by hardware and compiler flags.
void * p = ordered_malloc(s);
get()->push_back(numeric::interval<int>((int) p, int((char *)(p) + s)));
There are many platforms in which int is not the same number of bytes as
a pointer. Most commonly such casts will cause code to fail to port to
64 bit platforms.
Perhaps we can figure out how to overcome the compile error that caused
you to add the cast, or figure out something you can cast the pointer to
that will portably result in no loss of data, such as perhaps size_t.
Luke
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk