|
Boost : |
From: David B. Held (dheld_at_[hidden])
Date: 2002-08-07 18:10:43
"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
news:ais7bn$gl6$1_at_main.gmane.org...
> [...]
> get_type_id() gets the s_id associated with the target; it's a distinct
> number in the range of [0, no of pointed classes]. It is transformed
> into an index for lookups.
Isn't it true that get_type_id() make assumptions about the binary layout
of the class? That is undefined, let alone non-portable.
"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
news:ais5tv$d00$1_at_main.gmane.org...
> [...]
> Up to now I've just tested ptr.h with pointer.cpp; only one source file.
I
> think gcc is duplicating templates & static members everywhere but
> can be prevented with #pragma interface macros.
Is that portable?
> [...]
> Let's not forget that (int *) 0 + sizeof(double) will be equal to 0x20
since
> the addition multiplies sizeof(int) sizeof(double) times. It is so much
> easier with offsets.
I see that you might have the desired semantics with int* arithmetic, but
you convert to char* anyway, so why not use sizeof() directly with char*?
"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
news:ais1eq$aj$1_at_main.gmane.org...
> [...]
> If I use resize() instead, will it shrink down the allocated block
(exactly
> what I don't want) if the new size is smaller than the previous one?
Yes, it will. Which is why the correct solution is to put a check to see if
the new size is larger than the existing size, push_back until it is the
right size. And yes, that is probably just as expensive as it sounds.
> [...]
> ptrdiff_t is a macro, is therefore not flexible. offset was created to
> simplify pointer arithmetics and to remove some implicit headaches...
> [...]
How is ptrdiff_t being a macro "not flexible"? It should be defined as
the difference type for pointer arithmetic on any given platform, which
is what offset does.
Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk