|
xapian-core
2.0.0
|
Arithmetic operations with overflow checks. More...
#include <type_traits>
Include dependency graph for overflow.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| template<typename T1 , typename T2 , typename R > | |
| std::enable_if_t< std::is_unsigned_v< T1 > &&std::is_unsigned_v< T2 > &&std::is_unsigned_v< R >, bool > | add_overflows (T1 a, T2 b, R &res) |
| Addition with overflow checking. More... | |
| template<typename T1 , typename T2 , typename R > | |
| std::enable_if_t< std::is_unsigned_v< T1 > &&std::is_unsigned_v< T2 > &&std::is_unsigned_v< R >, bool > | sub_overflows (T1 a, T2 b, R &res) |
| Subtraction with overflow checking. More... | |
| template<typename T1 , typename T2 , typename R > | |
| std::enable_if_t< std::is_unsigned_v< T1 > &&std::is_unsigned_v< T2 > &&std::is_unsigned_v< R >, bool > | 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_t<std::is_unsigned_v<T1> && std::is_unsigned_v<T2> && std::is_unsigned_v<R>, bool> 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 HoneyDatabase::compact(), parse_unsigned(), EstimateOp::resolve(), and test_addoverflows1().
| std::enable_if_t<std::is_unsigned_v<T1> && std::is_unsigned_v<T2> && std::is_unsigned_v<R>, bool> 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 HoneyPostList::HoneyPostList(), HoneyCompact::merge_postlists(), HoneyCompact::PostlistCursor< const HoneyTable & >::next(), parse_unsigned(), Xapian::Document::Internal::remove_postings(), and test_muloverflows1().
| std::enable_if_t<std::is_unsigned_v<T1> && std::is_unsigned_v<T2> && std::is_unsigned_v<R>, bool> 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 EstimateOp::resolve(), and test_suboverflows1().