safe_numerics icon indicating copy to clipboard operation
safe_numerics copied to clipboard

docs: example differs from its description

Open hgkjshegfskef opened this issue 3 years ago • 2 comments

The example at https://www.boost.org/doc/libs/1_77_0/libs/safe_numerics/doc/html/eliminate_runtime_penalty/3.html is aimed to demonstrate how different type promotion policies and exception policies can be combined. The description says:

As before, we define a type safe_t to reflect our view of legal values for this program. This uses the automatic type promotion policy as well as the loose_trap_policy exception policy to enforce elimination of runtime penalties.

But safe_t is defined as:

using safe_t = safe_signed_range<
    -24,
    82,
    native,
    loose_exception_policy
>;

According to description it should perhaps be defined as:

using safe_t = safe_signed_range<
    -24,
    82,
    automatic,
    loose_trap_policy
>;

hgkjshegfskef avatar Sep 09 '21 09:09 hgkjshegfskef

Good to know that at least someone is reading the documents! Good catch. I've made the change on my local machine - let's hope that the example still compiles and runs !!!

robertramey avatar Sep 09 '21 16:09 robertramey

Thank you for being thorough with the documentation. While reading further, I have noticed a few more problems: e.g. some excerpts refer to boost::numeric, which I assume was the old name of the library, and things like that. Maybe I will just submit a PR to not bother you with changes. This one I just wasn't sure, since I am just learning about the library.

Re: this problem, looks like it compiles with the changes according to documentation wording: https://godbolt.org/z/EheKvPYeG

hgkjshegfskef avatar Sep 09 '21 17:09 hgkjshegfskef