|
Boost : |
Subject: Re: [boost] a safe integer library
From: Robert Ramey (ramey_at_[hidden])
Date: 2016-01-13 00:36:23
On 1/12/16 6:57 PM, Brook Milligan wrote:
> On Jan 12, 2016, at 7:30 PM, Robert Ramey <ramey_at_[hidden]> wrote:
>> I don't remember what I was thinking when I wrote that. But it might be that I didn't want users to use the function without checking the return value.
>
> Perhaps that is a more useful statement for the documentation. It is certainly more informative.
>
>>> This solution suggests that wrapping this particular construct in something that is unambiguously safe would be a good idea:
>>>
>>> template < typename R, typename T >
>>> bool is_convertible<R>(T const& t)
>>> { return checked_cast<R>(t).no_exception(); }
Within the design intention of the library of the library one would simply
safe_... x;
int y
try{
y = x; // or x = y;
}
catch(cont std::exception e &){
// cast failed
...
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk