Skip to content

Commit

Permalink
Use Policy to check for overflow in integer::operator-
Browse files Browse the repository at this point in the history
Also fixes an issue raised in #113.
  • Loading branch information
foonathan committed May 29, 2020
1 parent a0290b5 commit 40a4897
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/type_safe/integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class integer
{
static_assert(std::is_signed<integer_type>::value,
"cannot call unary minus on unsigned integer");
return -value_;
return integer(Policy::template do_multiplication(value_, integer_type(-1)));
}

/// \effects Increments the integer by one.
Expand Down

0 comments on commit 40a4897

Please sign in to comment.