22 constexpr
range(value_type a, value_type b)
24 , max_{std::move(b)} {
31 , max_{r.get_max()} {}
35 : min_{std::move(r.min_)}
36 , max_{std::move(r.max_)} {}
38 constexpr
auto get_min()
const {
return min_; }
39 constexpr
auto get_max()
const {
return max_; }
51 constexpr range& operator-=(
const V& v) {
58 constexpr range& operator*=(
const V& v) {
66 constexpr range& operator/=(
const V& v) {
74 constexpr range& pad(
const V& v) {
82 constexpr
void maintain_invariant() {
98 constexpr
range<t> make_range(
const t& a,
const t& b) {
104 template <
typename A,
typename B>
106 return std::make_tuple(a.get_min(), a.get_max()) ==
107 std::make_tuple(b.get_min(), b.get_max());
110 template <
typename A,
typename B>
115 template <
typename A,
typename B>
116 constexpr
auto operator+(
const range<A>& a,
const B& b) {
121 template <
typename A,
typename B>
122 constexpr
auto operator-(
const range<A>& a,
const B& b) {
127 template <
typename A,
typename B>
128 constexpr
auto operator*(
const range<A>& a,
const B& b) {
133 template <
typename A,
typename B>
134 constexpr
auto operator/(
const range<A>& a,
const B& b) {
141 template <
typename A,
typename B>
142 constexpr
auto padded(
const range<A>& a,
const B& b) {
147 template <
typename t>
148 constexpr
auto centre(
const range<t>& a) {
149 return (a.get_min() + a.get_max()) * t{0.5};
152 template <
typename t>
153 constexpr
auto dimensions(
const range<t>& a) {
154 return a.get_max() - a.get_min();
157 template <
typename T,
typename U,
typename V>
159 return (((x - in.get_min()) * dimensions(out)) / dimensions(in)) +
163 template <
typename T,
typename U>
164 constexpr
auto inside(
const T& t,
const range<U>& r) {
165 return r.get_min() <= t && t < r.get_max();
168 template <
typename T,
typename U>
169 constexpr
auto clamp(
const T& t,
const range<U>& r) {
172 return max(r.get_min(), min(r.get_max(), t));
177 template <
typename It,
typename T>
178 constexpr
auto accumulate_min(It begin, It end, T starting_value) {
179 return std::accumulate(
180 begin, end, starting_value, [](
const auto& a,
const auto& b) {
185 template <
typename It,
typename T>
186 constexpr
auto accumulate_max(It begin, It end, T starting_value) {
187 return std::accumulate(
188 begin, end, starting_value, [](
const auto& a,
const auto& b) {
193 template <
typename It>
194 constexpr
auto enclosing_range(It begin, It end) {
196 throw std::runtime_error(
"Can't minmax empty range.");
198 return make_range(accumulate_min(begin + 1, end, *begin),
199 accumulate_max(begin + 1, end, *begin));
Definition: allocator.h:6
constexpr range()
setters/getters
Definition: range.h:18
constexpr range & operator+=(const V &v)
mutators
Definition: range.h:44