Boost logo

Boost :

Subject: Re: [boost] [xint] Question about suitability, portability, and "Boostiness"
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2010-04-13 01:34:01


On 13 April 2010 01:26, Chad Nelson <chad.thecomfychair_at_[hidden]> wrote:
>
> That's easily done. It's what the aforementioned "quick digits" are used
> for at present. Of course, it means that the space taken up by those
> digits will be wasted on every integer that's larger than they can hold.
>

SBO = Small Buffer Optimization

You said the "quick digits" are inside the struct to which the xint
object holds a pointer, so using them requires dynamic allocation.

I picture it something like this:

    struct xint {
        union {
            internal_xint *ptr;
            intptr_t small;
        };
        xint() : small(1) {}
    };

Then you only allocate internal_xints on even addresses, so that if
(small&1), then the value of the xint is ashr(small, 1).

And that way I don't have to worry that a use of a common literal,
like xint(3), might throw an exception,


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk