Boost logo

Boost :

Subject: Re: [boost] a safe integer library
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2015-12-17 04:50:17


2015-12-17 9:12 GMT+01:00 Robert Ramey <ramey_at_[hidden]>:

I do have a policy to ignore errors. But I haven't tested it. I'm
> thinking I should eliminate it as it would defeat the whole purpose of the
> library.

I can see value in such policy. In the e documentation, in section
"Eliminate Runtime Cost" (
https://htmlpreview.github.io/?https://raw.githubusercontent.com/robertramey/safe_numerics/master/doc/html/tutorial/8.html)
you show a great application of the library. If I am interested in
improving performance still, I would change the policy form "throw upon
overflow" to "ignore overflow", in hope that the later skips the check
altogether.

Then, using type

safe_signed_range<Min, Max, automatic, ignore>;

Is still better than just `int`

First, it is distinct type than `int`. Secong, even if the compiler does
not help me, I am sending a clear message to other programmers: "this
variable is expected to hold a value within range, the person responsible
is the one that assigns the value: no-one else needs to check it.

Then I can only swap the policies in debug versus release modes.


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