Boost logo

Boost :

Subject: [boost] [safe_numerics] One more review
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2017-03-11 09:00:07

- What is your evaluation of the design?

Looks good, simple to use.

I'd like to see an additional statefull ExceptionPolicy that remembers
that an UB was triggered, but does not throw at all. Here's how it
could be used:

bool try_do_something(int& out) noexcept {
    using namespace boost::numeric;
    safe<int, native, lazy> x = INT_MAX;
    // remembers that error was triggered
    // ... other operations on `x`
    // ...

    if (!x.no_errors()) {
        // One of the operations triggered UB
        return false;

    out = x;
    return true;

- What is your evaluation of the implementation?

Checked a few border cases that I'm aware of. All of them were taken
care of in the library.


Missing BOOST_NORETURN in multiple places, for example
. Adding that attribute may result in better code generation and in
warnings suppression.

std::is_literal_type type trait is deprecated since C++17

More generic streaming operators could be profitable (better to use
basic_ostream<Char, Trait> instead of ostream)

Many operations may be decorated with noexcept

This macro seems broken
. Also looks like this class is not covered well with tests, because
shall not compile

There's a bunch of implicit conversions in the library
(BTW, have not found a body of this one). Would it be better to make
them explicit?

Those headers are very heavy
Try using <iosfwd> and making all the function below to use
`basic_ostream<Char, Trait>&`.

No need to define those in `namespace std`
. Defining those in `boost::numeric` namespace works fine (thanks to

I'd really like to see tests coverage for the library. This is pretty
simple to add, just follow the instructions from here:

- What is your evaluation of the documentation?

Good, very interesting examples.

- What is your evaluation of the potential usefulness of the library?

Useful. I was dealing with such problems in Boost.LexicalCast.

- Did you try to use the library? With what compiler? Did you have any problems?

Have not tried.

- How much effort did you put into your evaluation? A glance? A quick
reading? In-depth study?

About two hours of reading source code and docs.

- Are you knowledgeable about the problem domain?

A little bit, not an expert.

- Do you think the library should be accepted as a Boost library?

Yes, the library should be accepted.

Best regards,
Antony Polukhin

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