|
Boost : |
From: Fabrice Truillot (fte_at_[hidden])
Date: 2000-07-17 16:44:04
on 17.7.2000 21:54, Thant Tessman at thant_at_[hidden] wrote:
>
> Okay, here they are. I've also included a very simple test program.
> ("circ_ptr" isn't the greatest name, but in my original implementation
> they're called "Ptr".)
Can I suggest an optimisation ? In your RawHandle, you can use some sort of
union between the void* raw pointer and the boolean. On most
implementations, the pointers are always at least 2-byte aligned (4-bytes
for my Macintosh). So, you can use the least significant bit to store your
boolean.
Under CodeWarrior 5.3, MacOS, sizeof (RawPointer) == 8, and with the
proposed optimisation, 4 bytes.
Hints :
struct pointer_and_bit
{
void* ptr;
bool bit () { return (ptr & 1); };
void bit (bool b)
{
if (b) ptr |= 1;
else ptr &= ~1;
};
... operator -> ...
};
Sorry for this java/c++ pseudo-code. Some type cast must be applied too.
Fab'
________________________________________________________________________
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk