6#include "int_interval.hpp"
17template<
interval<
long long> Range>
19 using interval_type = interval<long long>;
21 constexpr static interval_type range = Range;
24 template<
interval_type RHS>
25 ranged_int(ranged_int<RHS>
const &rhs)
26 noexcept(range.finite() and RHS.finite() and range.lo >= RHS.lo and RHS.hi <= range.hi) :
27 _value(static_cast<value_type>(rhs._value))
29 if constexpr (not (range.finite() and RHS.finite() and range.lo >= RHS.lo and RHS.hi <= range.hi)) {
30 if (rhs.value < range.lo or rhs.value > range.hi) {
36 template<
interval_type RHS>
37 [[nodiscard]] ranged_int<range + RHS> operator+(ranged_int<RHS> rhs)
const noexcept(ranged_int<range + RHS>::finite())
39 using R = ranged_int<range + RHS>;
41 if constexpr (R::finite()) {
42 return R{_value + rhs._value, override_t{}};
45 auto lhs_ = wide_cast<long long>(_value);
46 auto rhs_ = wide_cast<long long>(rhs._value);
48 if (overflow_add(lhs_, rhs_, r)) {
55 template<
interval_type RHS>
56 [[nodiscard]] ranged_int<range - RHS> operator-(ranged_int<RHS> rhs)
const noexcept(ranged_int<range - RHS>::finite())
58 using R = ranged_int<range - RHS>;
60 if constexpr (R::finite()) {
61 return R{_value - rhs._value, override_t{}};
64 auto lhs_ = wide_cast<long long>(_value);
65 auto rhs_ = wide_cast<long long>(rhs._value);
67 if (overflow_sub(lhs_, rhs_, r)) {
75template<fixed_
string Literal>
78 constexpr long long value = from_string_literal(Literal);
80 return ranged_int<interval<value,value>>{value};
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11