Clingo
|
Additional (checked) math functions. More...
Functions | |
template<std::signed_integral T, std::signed_integral S> | |
auto | CppClingo::Util::check_cast (S in) -> bool |
Check if s of type S can be casted to T without loss. | |
template<std::integral T, std::integral S> | |
auto | CppClingo::Util::safe_cast (S in) -> T |
Cast S to T if possible. | |
template<std::signed_integral S> | |
auto | CppClingo::Util::check_add (S a, S b) -> std::optional< S > |
Add two integers checking overflows. | |
template<std::signed_integral S> | |
auto | CppClingo::Util::check_sub (S a, S b) -> std::optional< S > |
Subtract two integers checking overflows. | |
template<std::signed_integral S> | |
auto | CppClingo::Util::check_neg (S a) -> std::optional< S > |
Negate an integer checking overflows. | |
template<std::signed_integral S> | |
auto | CppClingo::Util::check_abs (S a) -> std::optional< S > |
The absolute of an integer checking overflows. | |
template<std::signed_integral S> | |
auto | CppClingo::Util::check_mul (S a, S b) -> std::optional< S > |
Multiply two integers checking overflows. | |
template<std::signed_integral S> | |
auto | CppClingo::Util::check_div (S a, S b) -> std::optional< S > |
Divide two integers checking overflows (truncating toward negative infinity). | |
template<std::signed_integral S> | |
auto | CppClingo::Util::check_mod (S a, S b) -> std::optional< S > |
Modulo of two integers checking overflows (truncating toward negative infinity). | |
template<std::signed_integral S> | |
auto | CppClingo::Util::check_pow (S a, S b) -> std::optional< S > |
Power of the given integers checking overflows. | |
Additional (checked) math functions.
auto CppClingo::Util::check_add | ( | S | a, |
S | b | ||
) | -> std::optional<S> |
Add two integers checking overflows.
Fallback for the general case.
auto CppClingo::Util::check_mul | ( | S | a, |
S | b | ||
) | -> std::optional<S> |
Multiply two integers checking overflows.
Fallback for the general case.
auto CppClingo::Util::check_pow | ( | S | a, |
S | b | ||
) | -> std::optional<S> |
Power of the given integers checking overflows.
Note that a^0 = 1
for all values of a
and a^b=0
whenever b
is less than zero.
auto CppClingo::Util::check_sub | ( | S | a, |
S | b | ||
) | -> std::optional<S> |
Subtract two integers checking overflows.
Fallback for the general case.