From 3516c546cae3f64e424ef1837ed5c08a9267e910 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 17 Aug 2023 12:55:43 +0200 Subject: [PATCH] interval: add contains() method Signed-off-by: Simon Rozman --- include/stdex/interval.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/stdex/interval.hpp b/include/stdex/interval.hpp index aff099d87..c4c7fa84e 100644 --- a/include/stdex/interval.hpp +++ b/include/stdex/interval.hpp @@ -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 >>