Skip to content

Commit

Permalink
Add TRange contains(TRange&) overload (#2678)
Browse files Browse the repository at this point in the history
Provides an easy way to check if one range is a subset of another.
  • Loading branch information
mikee47 authored Oct 21, 2023
1 parent 68a6e24 commit eaaf2a8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sming/Core/Data/Range.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ template <typename T> struct TRange {
return (value >= min) && (value <= max);
}

/**
* @brief Determine if range contains another range (subset)
*/
template <typename Q> bool contains(const TRange<Q>& value) const
{
return contains(value.min) && contains(value.max);
}

/**
* @brief Clip values to within the range
*/
Expand Down

0 comments on commit eaaf2a8

Please sign in to comment.