interval: add contains() method

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-08-17 12:55:43 +02:00
parent 72ce0a03e5
commit 3516c546ca

View File

@ -77,6 +77,15 @@ namespace stdex
/// \returns true if intervals are different or false otherwise
///
inline bool operator!=(const interval& other) const { return !operator==(other); }
///
/// Is value in interval?
///
/// \param[in] x Value to test
///
/// \returns true if x is in [start, end) or false otherwise
///
inline bool contains(_In_ T x) const { return start <= x && x < end; }
};
template <class T, class _Alloc = std::allocator<interval<T>>>