xapian-core
1.4.27
|
Arithmetic operations with overflow checks. More...
#include <type_traits>
Go to the source code of this file.
Functions | |
template<typename T1 , typename T2 , typename R > | |
std::enable_if< std::is_unsigned< T1 >::value &&std::is_unsigned< T2 >::value &&std::is_unsigned< R >::value, bool >::type | add_overflows (T1 a, T2 b, R &res) |
Addition with overflow checking. More... | |
template<typename T1 , typename T2 , typename R > | |
std::enable_if< std::is_unsigned< T1 >::value &&std::is_unsigned< T2 >::value &&std::is_unsigned< R >::value, bool >::type | sub_overflows (T1 a, T2 b, R &res) |
Subtraction with overflow checking. More... | |
template<typename T1 , typename T2 , typename R > | |
std::enable_if< std::is_unsigned< T1 >::value &&std::is_unsigned< T2 >::value &&std::is_unsigned< R >::value, bool >::type | mul_overflows (T1 a, T2 b, R &res) |
Multiplication with overflow checking. More... | |
Arithmetic operations with overflow checks.
The operations are implemented with compiler builtins or equivalent where possible, so the overflow check will typically just require a check of the processor's overflow or carry flag.
Definition in file overflow.h.
std::enable_if<std::is_unsigned<T1>::value && std::is_unsigned<T2>::value && std::is_unsigned<R>::value, bool>::type add_overflows | ( | T1 | a, |
T2 | b, | ||
R & | res | ||
) |
Addition with overflow checking.
Add a and b in infinite precision, and store the result in res.
Where possible, compiler built-ins or intrinsics are used to try to ensure minimal overhead from the overflow check.
Currently only supported when types involved are unsigned.
Definition at line 58 of file overflow.h.
Referenced by parse_unsigned(), test_addoverflows1(), and throw_timeout().
std::enable_if<std::is_unsigned<T1>::value && std::is_unsigned<T2>::value && std::is_unsigned<R>::value, bool>::type mul_overflows | ( | T1 | a, |
T2 | b, | ||
R & | res | ||
) |
Multiplication with overflow checking.
Multiply a and b in infinite precision, and store the result in res.
Where possible, compiler built-ins or intrinsics are used to try to ensure minimal overhead from the overflow check.
Currently only supported when types involved are unsigned.
Definition at line 188 of file overflow.h.
Referenced by parse_unsigned(), Xapian::Document::Internal::remove_postings(), and test_muloverflows1().
std::enable_if<std::is_unsigned<T1>::value && std::is_unsigned<T2>::value && std::is_unsigned<R>::value, bool>::type sub_overflows | ( | T1 | a, |
T2 | b, | ||
R & | res | ||
) |
Subtraction with overflow checking.
Subtract b from a in infinite precision, and store the result in res.
Where possible, compiler built-ins or intrinsics are used to try to ensure minimal overhead from the overflow check.
Currently only supported when types involved are unsigned.
Definition at line 125 of file overflow.h.
Referenced by test_suboverflows1().