In C ++ 14 there is no direct equivalent to such a function, but for smaller types with quick equality comparison you can use std::clamp :
if (val == std::clamp(val, low, high)) { ... }
Alternatively, you can simply write your own function to test for this:
template <typename T> bool IsInBounds(const T& value, const T& low, const T& high) { return !(value < low) && (value < high); }
This checks if value in the range [low, high). If you want a range of [low, high], you should write this as
template <typename T> bool IsInBounds(const T& value, const T& low, const T& high) { return !(value < low) && !(high < value); }
Notice how this is defined exclusively from the point of view of operator < , which means that any class that only supports operator < can be used here.
Similarly, a custom comparator is used here:
template <typename T, typename R, typename Comparator> bool IsInBounds(const T& value, const R& low, const R& high, Comparator comp) { return !comp(value, low) && comp(value, high); }
This last has a nice advantage: low and high should not be of the same type as value , and as long as the comparator can handle this, it will work fine.
Hope this helps!