2014-06-09 13:35:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-09-25 22:14:10 +00:00
|
|
|
#include <type_traits>
|
|
|
|
|
2015-09-08 13:53:28 +00:00
|
|
|
template<typename T1, typename T2> struct range_t
|
2014-06-09 13:35:35 +00:00
|
|
|
{
|
2015-09-08 13:53:28 +00:00
|
|
|
T1 _min; // first value
|
|
|
|
T2 _max; // second value
|
|
|
|
};
|
2014-06-09 13:35:35 +00:00
|
|
|
|
2015-09-08 13:53:28 +00:00
|
|
|
template<typename T1, typename T2> constexpr range_t<std::decay_t<T1>, std::decay_t<T2>> make_range(T1&& _min, T2&& _max)
|
|
|
|
{
|
|
|
|
return{ std::forward<T1>(_min), std::forward<T2>(_max) };
|
|
|
|
}
|
2014-06-09 13:35:35 +00:00
|
|
|
|
2015-09-08 13:53:28 +00:00
|
|
|
template<typename T1, typename T2, typename T> constexpr bool operator <(const range_t<T1, T2>& range, const T& value)
|
|
|
|
{
|
|
|
|
return range._min < value && range._max < value;
|
|
|
|
}
|
2014-06-09 13:35:35 +00:00
|
|
|
|
2015-09-08 13:53:28 +00:00
|
|
|
template<typename T1, typename T2, typename T> constexpr bool operator <(const T& value, const range_t<T1, T2>& range)
|
|
|
|
{
|
|
|
|
return value < range._min && value < range._max;
|
|
|
|
}
|
2014-06-09 13:35:35 +00:00
|
|
|
|
2015-09-08 13:53:28 +00:00
|
|
|
template<typename T1, typename T2, typename T> constexpr bool operator ==(const range_t<T1, T2>& range, const T& value)
|
|
|
|
{
|
|
|
|
return !(value < range._min) && !(range._max < value);
|
|
|
|
}
|
2014-06-09 13:35:35 +00:00
|
|
|
|
2015-09-08 13:53:28 +00:00
|
|
|
template<typename T1, typename T2, typename T> constexpr bool operator ==(const T& value, const range_t<T1, T2>& range)
|
|
|
|
{
|
|
|
|
return !(value < range._min) && !(range._max < value);
|
|
|
|
}
|