17 #ifndef GZ_MATH_INTERVAL_HH_
18 #define GZ_MATH_INTERVAL_HH_
23 #include <type_traits>
26 #include <gz/math/config.hh>
31 inline namespace GZ_MATH_VERSION_NAMESPACE {
58 T _leftValue,
bool _leftClosed,
59 T _rightValue,
bool _rightClosed)
60 : leftValue(
std::move(_leftValue)),
61 rightValue(
std::move(_rightValue)),
62 leftClosed(_leftClosed),
63 rightClosed(_rightClosed)
72 Open(T _leftValue, T _rightValue)
117 public:
const T &
LeftValue()
const {
return this->leftValue; }
125 public:
const T &
RightValue()
const {
return this->rightValue; }
137 if (this->leftClosed && this->rightClosed)
139 return this->rightValue < this->leftValue;
141 return this->rightValue <= this->leftValue;
149 if (this->leftClosed && this->rightClosed)
151 return this->leftValue <= _value && _value <= this->rightValue;
153 if (this->leftClosed)
155 return this->leftValue <= _value && _value < this->rightValue;
157 if (this->rightClosed)
159 return this->leftValue < _value && _value <= this->rightValue;
161 return this->leftValue < _value && _value < this->rightValue;
169 if (this->Empty() || _other.
Empty())
173 if (!this->leftClosed && _other.leftClosed)
175 if (_other.leftValue <= this->leftValue)
182 if (_other.leftValue < this->leftValue)
187 if (!this->rightClosed && _other.rightClosed)
189 if (this->rightValue <= _other.rightValue)
196 if (this->rightValue < _other.rightValue)
209 if (this->Empty() || _other.
Empty())
213 if (this->rightClosed && _other.leftClosed)
215 if (this->rightValue < _other.leftValue)
222 if (this->rightValue <= _other.leftValue)
227 if (_other.rightClosed && this->leftClosed)
229 if (_other.rightValue < this->leftValue)
236 if (_other.rightValue <= this->leftValue)
249 return this->Contains(_other) && _other.
Contains(*
this);
257 return !this->Contains(_other) || !_other.
Contains(*
this);
267 return _out << (_interval.leftClosed ?
"[" :
"(")
268 << _interval.leftValue <<
", " << _interval.rightValue
269 << (_interval.rightClosed ?
"]" :
")");
273 private: T leftValue{0};
275 private: T rightValue{0};
277 private:
bool leftClosed{
false};
279 private:
bool rightClosed{
false};
284 constexpr Interval<T> gUnboundedInterval =