Boost logo

Boost :

Subject: Re: [boost] safe integer library -- the scope
From: Robert Ramey (ramey_at_[hidden])
Date: 2015-12-14 13:14:51


On 12/14/15 9:45 AM, Andrzej Krzemienski wrote:
> 2015-12-14 18:34 GMT+01:00 Robert Ramey <ramey_at_[hidden]>:
>
>> On 12/14/15 9:21 AM, Andrzej Krzemienski wrote:
>>
>>> 2015-12-14 17:39 GMT+01:00 Robert Ramey <ramey_at_[hidden]>:
>>>
>>
>> Ok, I see. So, there is something more to it than just the set of values.
>>> safe<T> does not check upon conversion from T.
>>>
>>
>> I believe it does. If it doesn't it's a mistake.
>
>
> It would make sense to skip the check:
>
> int i = whatever();
> safe<int> si (i); // this just cannot go wrong.

It does that. I guess I misunderstood the comment.

Basically

given a binary operation R <- T op U where either T or U are safe types,
the operation is checked at runtime if and only if

a) either T or U is a safe type
b) the result cannot be guaranteed to fit into a type R

Robert Ramey


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