Skip to content

Commit 40a4897

Browse files
committed
Use Policy to check for overflow in integer::operator-
Also fixes an issue raised in #113.
1 parent a0290b5 commit 40a4897

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

include/type_safe/integer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class integer
194194
{
195195
static_assert(std::is_signed<integer_type>::value,
196196
"cannot call unary minus on unsigned integer");
197-
return -value_;
197+
return integer(Policy::template do_multiplication(value_, integer_type(-1)));
198198
}
199199

200200
/// \effects Increments the integer by one.

0 commit comments

Comments
 (0)