|
Stratax 0.4.0rc1
|
Shared validation for division operands and integral shift counts. More...
#include <stratax/core/dtypes/Concepts.hpp>#include <stratax/exceptions/Exceptions.hpp>#include <climits>#include <cstdint>#include <limits>#include <type_traits>

Go to the source code of this file.
Functions | |
| template<Numeric L, Numeric R> | |
| void | stratax::core::validation::require_valid_division (const L &lhs, const R &rhs) |
| Rejects zero divisors and unrepresentable native signed division. | |
| template<typename Value , Integral Count> | |
| constexpr bool | stratax::core::validation::valid_shift_count (const Count &count) noexcept |
| Tests whether a shift count is valid for a value type. | |
| template<typename Value , Integral Count> | |
| void | stratax::core::validation::require_valid_shift_count (const Count &count) |
| Rejects shift counts outside the stored value type's bit width. | |
Shared validation for division operands and integral shift counts.
Definition in file NumericValidation.hpp.
| void stratax::core::validation::require_valid_division | ( | const L & | lhs, |
| const R & | rhs | ||
| ) |
Rejects zero divisors and unrepresentable native signed division.
Integral checks use the type of the native lhs / rhs expression, after integer promotion and usual arithmetic conversions. Result-container dtype promotion occurs later and does not change whether that expression is valid. A narrow signed minimum divided by minus one can therefore be valid when the expression evaluates in a wider signed type.
| L | Numeric left operand type. |
| R | Numeric right operand type. |
| lhs | Original left element or scalar, before result dtype conversion. |
| rhs | Original right element or scalar, before result dtype conversion. |
| Exceptions::ZeroDivisionError | If rhs equals zero, including floating-point signed zero or complex zero. |
| Exceptions::OverflowError | If integral division would evaluate the native signed expression type's minimum value divided by minus one. |
Definition at line 38 of file NumericValidation.hpp.
| void stratax::core::validation::require_valid_shift_count | ( | const Count & | count | ) |
Rejects shift counts outside the stored value type's bit width.
count is valid for Value. | Exceptions::ValueError | If count is negative or is not smaller than the bit width of Value. |
Definition at line 97 of file NumericValidation.hpp.
|
constexprnoexcept |
Tests whether a shift count is valid for a value type.
| Value | Type of the value being shifted. |
| Count | Integral shift-count type. |
| count | Shift count to validate. |
true when count is non-negative and smaller than the bit width of Value; otherwise false. Definition at line 72 of file NumericValidation.hpp.