1 #ifndef CAPSTONE_BOUNDS_H 2 #define CAPSTONE_BOUNDS_H 9 double const lower, upper;
11 inline Bounds (
double lower,
double upper)
12 : lower {lower < upper ? lower : upper}
13 , upper {lower < upper ? upper : lower}
15 if (!std::isnormal (lower) && lower != 0.0)
16 throw std::logic_error (
"Real boundary expected; got " + std::to_string (lower));
17 if (!std::isnormal (upper) && upper != 0.0)
18 throw std::logic_error (
"Real boundary expected; got " + std::to_string (upper));
23 return lower == other.lower && upper == other.upper;
27 [[nodiscard]]
inline bool contains (
double val)
const {
28 if (val == lower)
return true;
29 return val >= lower && val < upper;
36 inline std::size_t operator() (
Bounds const & bounds)
const noexcept {
37 auto hash_lower = std::hash <double> {}(bounds.lower);
38 auto hash_upper = std::hash <double> {}(bounds.upper);
41 return hash_lower ^ (hash_upper << 1);
45 #endif //CAPSTONE_BOUNDS_H bool operator==(Bounds other) const
compare the given bounds for equality
Store lower inclusive and upper exclusive boundaries as container for interaction with random number ...
bool contains(double val) const
Check whether the given value is within this object's boundaries.