Boost logo

Boost :

Subject: Re: [boost] [xint] Third release is ready, requesting preliminary review
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-05-01 14:44:57

----- Original Message -----
From: "Chad Nelson" <chad.thecomfychair_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, May 01, 2010 8:05 PM
Subject: Re: [boost] [xint] Third release is ready, requesting preliminary review

> Hash: SHA1
> On 05/01/2010 01:01 PM, vicente.botet wrote:
>>>>> however so far i have a suggestion about fixed_integer
>>>>> for me it is counter intuitive that a fixed_integer<N> allocates
>>>>> memory on the heap rather than on the stack [...]
>>>> That was a tough decision. I started out with it on the heap, but
>>>> there's no way to use the more-efficient swap(), operator=, or copy/move
>>>> constructors that way. The best choice came down to which set of
>>>> operations happens more commonly: swapping and assignment or creating a
>>>> new object. I have no way of objectively measuring that for other
>>>> people's code, but for my own, swapping and assignment edge out object
>>>> creation, slightly.
>>> that argument is enough for me and anyway it's _your_ decision
>>> i only make a suggestion
>> What about implementing both strategies, either as separated
>> classes, or adding a template parameter?
> It could be done with separated classes, but I don't see any way to do
> it with a template parameter; the array would have to be included in the
> class itself if it was ever going to be used, and I don't know of any
> way to eliminate it via a template parameter.

With an addition template parameter you can for example specialize

template <std::size_t N, bool HeapAllocated>
class fixed_integer;

template <std::size_t N>
class fixed_integer<N, true> ... // your current implementation

template <std::size_t N>
class fixed_integer<N, false> ... // implementation suggested by Pavel


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