File indexing completed on 2026-09-27 09:14:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef LAGER_CORE_INTERVAL_LOADED
0021 #define LAGER_CORE_INTERVAL_LOADED
0022
0023
0024
0025
0026 namespace lager {
0027 template <class T> struct interval {
0028 using value_type = T;
0029 value_type min;
0030 value_type max;
0031 constexpr interval() = default;
0032 constexpr interval(const value_type min, const value_type max)
0033 : min{min}, max{max} {}
0034 constexpr interval(const std::pair<value_type, value_type>& rhs)
0035 : min{rhs.first}, max{rhs.second} {}
0036 constexpr bool includes(const value_type value) const {
0037 return value > min && value < max;
0038 }
0039 constexpr bool excludes(const value_type value) const {
0040 return !includes(value);
0041 }
0042 constexpr T width() const { return max - min; }
0043
0044 constexpr operator std::pair<value_type, value_type>() const {
0045 return std::make_pair(min, max);
0046 }
0047 constexpr interval operator*(const double rhs) const {
0048 return {min * rhs, max * rhs};
0049 }
0050 constexpr interval operator/(const double rhs) const {
0051 return operator*(1 / rhs);
0052 }
0053 interval operator*=(const double rhs) { *this = operator*(rhs); }
0054 interval operator/=(const double rhs) { *this = operator/(rhs); }
0055 };
0056 }
0057
0058 #endif