-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_2dim.hpp
368 lines (339 loc) · 25.4 KB
/
_2dim.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
//Copyright (C) 2014-2017, 2019, 2021 I
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include<type_traits>
#pragma once
namespace will{
namespace two_dim{
namespace tag{
struct point{};
struct size{};
struct point_pair{};
struct point_and_size{};
}
template<typename T>struct attribute_traits;
template<typename T>
struct xy{
T x, y;
using element_type = T;
constexpr bool operator==(const xy<T>& other)noexcept{return x == other.x && y == other.y;}
constexpr bool operator!=(const xy<T>& other)noexcept{return !(*this == other);}
#if 0
template<typename U, std::enable_if_t<std::is_same<tag::point, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{using et = typename attribute_traits<std::decay_t<U>>::element_type;return attribute_traits<U>::create(static_cast<et>(x), static_cast<et>(y));}
template<typename U, std::enable_if_t<std::is_same<tag::point, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert();}
#endif
};
template<typename T>
struct attribute_traits<xy<T>>{
using tag_type = tag::point;
using element_type = T;
static constexpr T x(const xy<T>& xy)noexcept{return xy.x;}
static constexpr T y(const xy<T>& xy)noexcept{return xy.y;}
static constexpr xy<T> create(T x, T y)noexcept{return {x, y};}
};
template<typename T>
struct wh{
T w, h;
using element_type = T;
constexpr bool operator==(const wh<T>& other)noexcept{return w == other.w && h == other.h;}
constexpr bool operator!=(const wh<T>& other)noexcept{return !(*this == other);}
#if 0
template<typename U, std::enable_if_t<std::is_same<tag::size, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{using et = typename attribute_traits<std::decay_t<U>>::element_type;return attribute_traits<U>::create(static_cast<et>(w), static_cast<et>(h));}
template<typename U, std::enable_if_t<std::is_same<tag::size, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert();}
#endif
};
template<typename T>
struct attribute_traits<wh<T>>{
using tag_type = tag::size;
using element_type = T;
static constexpr T w(const wh<T>& wh)noexcept{return wh.w;}
static constexpr T h(const wh<T>& wh)noexcept{return wh.h;}
static constexpr wh<T> create(T w, T h)noexcept{return {w, h};}
};
template<typename T>
struct xyxy{
xy<T> _1, _2;
using element_type = T;
#if 0
template<typename U, std::enable_if_t<std::is_same<tag::point_pair, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{using et = typename attribute_traits<std::decay_t<U>>::element_type;return attribute_traits<U>::create(static_cast<et>(_1.x), static_cast<et>(_1.y), static_cast<et>(_2.x), static_cast<et>(_2.y));}
template<typename U, std::enable_if_t<std::is_same<tag::point_pair, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert();}
#endif
};
template<typename T>
struct attribute_traits<xyxy<T>>{
using tag_type = tag::point_pair;
using element_type = T;
static constexpr xy<T> _1(const xyxy<T>& xyxy)noexcept{return xyxy._1;}
static constexpr xy<T> _2(const xyxy<T>& xyxy)noexcept{return xyxy._2;}
static constexpr T x1(const xyxy<T>& xyxy)noexcept{return xyxy._1.x;}
static constexpr T y1(const xyxy<T>& xyxy)noexcept{return xyxy._1.y;}
static constexpr T x2(const xyxy<T>& xyxy)noexcept{return xyxy._2.x;}
static constexpr T y2(const xyxy<T>& xyxy)noexcept{return xyxy._2.y;}
static constexpr xyxy<T> create(T x1, T y1, T x2, T y2)noexcept{return {{x1, y1}, {x2, y2}};}
static constexpr xyxy<T> create(const xy<T>& _1, const xy<T>& _2)noexcept{return {_1, _2};}
template<typename U, typename V>
static constexpr xyxy<T> create(const xy<U>& _1, const xy<V>& _2)noexcept{return {{static_cast<T>(_1.x), static_cast<T>(_1.y)}, {static_cast<T>(_2.x), static_cast<T>(_2.y)}};}
};
template<typename T, typename U = T>
struct xywh{
xy<T> xy;
wh<U> wh;
using point_element_type = T;
using size_element_type = U;
constexpr bool operator==(const xywh<T, U>& other)noexcept{return xy == other.xy && wh == other.wh;}
constexpr bool operator!=(const xywh<T, U>& other)noexcept{return !(*this == other);}
#if 0
template<typename V, std::enable_if_t<std::is_same<tag::point_and_size, typename attribute_traits<std::decay_t<V>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr V convert()const noexcept{using pet = typename attribute_traits<std::decay_t<V>>::point_element_type;using set = typename attribute_traits<std::decay_t<V>>::size_element_type;return attribute_traits<V>::create(static_cast<pet>(xy.x), static_cast<pet>(xy.y), static_cast<set>(wh.w), static_cast<set>(wh.h));}
template<typename V, std::enable_if_t<std::is_same<tag::point_and_size, typename attribute_traits<std::decay_t<V>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator V()const noexcept{return convert();}
#endif
};
template<typename T, typename U>
struct attribute_traits<xywh<T, U>>{
using tag_type = tag::point_and_size;
using point_element_type = T;
using size_element_type = U;
static constexpr two_dim::xy<T> xy(const xywh<T, U>& xywh)noexcept{return xywh.xy;}
static constexpr two_dim::wh<U> wh(const xywh<T, U>& xywh)noexcept{return xywh.wh;}
static constexpr T x(const xywh<T, U>& xywh)noexcept{return xywh.xy.x;}
static constexpr T y(const xywh<T, U>& xywh)noexcept{return xywh.xy.y;}
static constexpr U w(const xywh<T, U>& xywh)noexcept{return xywh.wh.w;}
static constexpr U h(const xywh<T, U>& xywh)noexcept{return xywh.wh.h;}
static constexpr xywh<T, U> create(T x, T y, U w, U h)noexcept{return {{x, y}, {w, h}};}
static constexpr xywh<T, U> create(const two_dim::xy<T>& xy, const two_dim::wh<U>& wh)noexcept{return {xy, wh};}
template<typename V, typename S>
static constexpr xywh<T, U> create(const two_dim::xy<V>& xy, const two_dim::wh<S>& wh)noexcept{return {{static_cast<T>(xy.x), static_cast<T>(xy.y)}, {static_cast<U>(wh.w), static_cast<U>(wh.h)}};}
};
namespace detail{
template<typename>struct size_attribute_proxy;
template<typename T>
struct point_attribute_proxy:T{
using element_type = typename attribute_traits<T>::element_type;
constexpr element_type x()const noexcept{return attribute_traits<T>::x(*this);}
constexpr element_type y()const noexcept{return attribute_traits<T>::y(*this);}
template<typename U, std::enable_if_t<std::is_same<tag::point, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{using et = typename attribute_traits<std::decay_t<U>>::element_type;return attribute_traits<U>::create(static_cast<et>(x()), static_cast<et>(y()));}
template<typename U, std::enable_if_t<std::is_same<tag::point, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert<U>();}
};
template<typename T>
struct size_attribute_proxy:T{
using element_type = typename attribute_traits<T>::element_type;
constexpr element_type w()const noexcept{return attribute_traits<T>::w(*this);}
constexpr element_type h()const noexcept{return attribute_traits<T>::h(*this);}
template<typename U, std::enable_if_t<std::is_same<tag::size, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{using et = typename attribute_traits<std::decay_t<U>>::element_type;return attribute_traits<U>::create(static_cast<et>(w()), static_cast<et>(h()));}
template<typename U, std::enable_if_t<std::is_same<tag::size, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert<U>();}
};
template<typename T>
struct point_pair_attribute_proxy:T{
using element_type = typename attribute_traits<T>::element_type;
constexpr decltype(attribute_traits<T>::_1(std::declval<T>())) _1()const noexcept{return attribute_traits<T>::_1(*this);}
constexpr decltype(attribute_traits<T>::_2(std::declval<T>())) _2()const noexcept{return attribute_traits<T>::_2(*this);}
constexpr element_type x1()const noexcept{return attribute_traits<T>::x1(*this);}
constexpr element_type y1()const noexcept{return attribute_traits<T>::y1(*this);}
constexpr element_type x2()const noexcept{return attribute_traits<T>::x2(*this);}
constexpr element_type y2()const noexcept{return attribute_traits<T>::y2(*this);}
template<typename U, std::enable_if_t<std::is_same<tag::point_pair, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{return attribute_traits<U>::create(_1(), _2());}
template<typename U, std::enable_if_t<std::is_same<tag::point_pair, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert<U>();}
template<typename U, std::enable_if_t<std::is_same<tag::point_and_size, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{return attribute_traits<U>::create(_1(), _2()-_1());}
template<typename U, std::enable_if_t<std::is_same<tag::point_and_size, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert<U>();}
};
template<typename T>
struct point_and_size_attribute_proxy:T{
using point_element_type = typename attribute_traits<T>::point_element_type;
using size_element_type = typename attribute_traits<T>::size_element_type;
constexpr decltype(attribute_traits<T>::xy(std::declval<T>())) xy()const noexcept{return attribute_traits<T>::xy(*this);}
constexpr decltype(attribute_traits<T>::wh(std::declval<T>())) wh()const noexcept{return attribute_traits<T>::wh(*this);}
constexpr point_element_type x()const noexcept{return attribute_traits<T>::x(*this);}
constexpr point_element_type y()const noexcept{return attribute_traits<T>::y(*this);}
constexpr size_element_type w()const noexcept{return attribute_traits<T>::w(*this);}
constexpr size_element_type h()const noexcept{return attribute_traits<T>::h(*this);}
template<typename U, std::enable_if_t<std::is_same<tag::point_and_size, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{return attribute_traits<U>::create(xy(), wh());}
template<typename U, std::enable_if_t<std::is_same<tag::point_and_size, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert<U>();}
template<typename U, std::enable_if_t<std::is_same<tag::point_pair, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr U convert()const noexcept{return attribute_traits<U>::create(xy(), xy()+wh());}
template<typename U, std::enable_if_t<std::is_same<tag::point_pair, typename attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr operator U()const noexcept{return convert<U>();}
};
}
template<typename T>
class attribute_proxy: public
std::conditional_t<
std::is_same<tag::point, typename attribute_traits<T>::tag_type>::value,
detail::point_attribute_proxy<T>,
std::conditional_t<
std::is_same<tag::size, typename attribute_traits<T>::tag_type>::value,
detail::size_attribute_proxy<T>,
std::conditional_t<
std::is_same<tag::point_pair, typename attribute_traits<T>::tag_type>::value,
detail::point_pair_attribute_proxy<T>,
std::conditional_t<
std::is_same<tag::point_and_size, typename attribute_traits<T>::tag_type>::value,
detail::point_and_size_attribute_proxy<T>,
void
>>>>{
using parent_type = std::conditional_t<
std::is_same<tag::point, typename attribute_traits<T>::tag_type>::value,
detail::point_attribute_proxy<T>,
std::conditional_t<
std::is_same<tag::size, typename attribute_traits<T>::tag_type>::value,
detail::size_attribute_proxy<T>,
std::conditional_t<
std::is_same<tag::point_pair, typename attribute_traits<T>::tag_type>::value,
detail::point_pair_attribute_proxy<T>,
std::conditional_t<
std::is_same<tag::point_and_size, typename attribute_traits<T>::tag_type>::value,
detail::point_and_size_attribute_proxy<T>,
void
>>>>;
public:
constexpr attribute_proxy(const T& t)noexcept:parent_type{t}{}
constexpr attribute_proxy(const attribute_proxy&)noexcept = default;
constexpr attribute_proxy(attribute_proxy&&)noexcept = default;
};
template<typename T>
struct attribute_traits<detail::point_attribute_proxy<T>>{
using tag_type = tag::point;
using element_type = typename attribute_traits<T>::element_type;
static constexpr element_type x(const detail::point_attribute_proxy<T>& xy)noexcept{return xy.x();}
static constexpr element_type y(const detail::point_attribute_proxy<T>& xy)noexcept{return xy.y();}
static constexpr detail::point_attribute_proxy<T> create(element_type x, element_type y)noexcept{return attribute_proxy<T>{attribute_traits<T>::create(x, y)};}
};
template<typename T>
struct attribute_traits<detail::size_attribute_proxy<T>>{
using tag_type = tag::size;
using element_type = typename attribute_traits<T>::element_type;
static constexpr element_type w(const detail::size_attribute_proxy<T>& wh)noexcept{return wh.w();}
static constexpr element_type h(const detail::size_attribute_proxy<T>& wh)noexcept{return wh.h();}
static constexpr detail::size_attribute_proxy<T> create(element_type w, element_type h)noexcept{return attribute_proxy<T>{attribute_traits<T>::create(w, h)};}
};
template<typename T>
struct attribute_traits<detail::point_pair_attribute_proxy<T>>{
using tag_type = tag::point_pair;
using element_type = typename attribute_traits<T>::element_type;
static constexpr auto _1(const detail::point_pair_attribute_proxy<T>& xyxy)noexcept->decltype(xyxy._1()){return xyxy._1();}
static constexpr auto _2(const detail::point_pair_attribute_proxy<T>& xyxy)noexcept->decltype(xyxy._2()){return xyxy._2();}
static constexpr element_type x1(const detail::point_pair_attribute_proxy<T>& xyxy)noexcept{return xyxy.x1();}
static constexpr element_type y1(const detail::point_pair_attribute_proxy<T>& xyxy)noexcept{return xyxy.y1();}
static constexpr element_type x2(const detail::point_pair_attribute_proxy<T>& xyxy)noexcept{return xyxy.x2();}
static constexpr element_type y2(const detail::point_pair_attribute_proxy<T>& xyxy)noexcept{return xyxy.y2();}
static constexpr detail::point_pair_attribute_proxy<T> create(element_type x1, element_type y1, element_type x2, element_type y2)noexcept{return attribute_proxy<T>{attribute_traits<T>::create(x1, y1, x2, y2)};}
};
template<typename T>
struct attribute_traits<detail::point_and_size_attribute_proxy<T>>{
using tag_type = tag::point_and_size;
using point_element_type = typename attribute_traits<T>::point_element_type;
using size_element_type = typename attribute_traits<T>::size_element_type;
static constexpr auto xy(const detail::point_and_size_attribute_proxy<T>& xywh)noexcept->decltype(xywh.xy()){return xywh.xy();}
static constexpr auto wh(const detail::point_and_size_attribute_proxy<T>& xywh)noexcept->decltype(xywh.wh()){return xywh.wh();}
static constexpr point_element_type x(const detail::point_and_size_attribute_proxy<T>& xywh)noexcept{return xywh.x();}
static constexpr point_element_type y(const detail::point_and_size_attribute_proxy<T>& xywh)noexcept{return xywh.y();}
static constexpr size_element_type w(const detail::point_and_size_attribute_proxy<T>& xywh)noexcept{return xywh.w();}
static constexpr size_element_type h(const detail::point_and_size_attribute_proxy<T>& xywh)noexcept{return xywh.h();}
static constexpr detail::point_and_size_attribute_proxy<T> create(point_element_type x, point_element_type y, size_element_type w, size_element_type h)noexcept{return attribute_proxy<T>{attribute_traits<T>::create(x, y, w, h)};}
};
template<typename T>
constexpr attribute_proxy<std::decay_t<T>> attribute(T&& t)noexcept{return {std::forward<T>(t)};}
template<typename T, typename U>
constexpr T attribute(U&& u)noexcept{return attribute(std::forward<U>(u));}
}
}
template<typename T, typename U, std::enable_if_t<std::is_same<will::two_dim::tag::point, typename will::two_dim::attribute_traits<std::decay_t<T>>::tag_type>::value && std::is_same<will::two_dim::tag::point, typename will::two_dim::attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr will::two_dim::attribute_proxy<will::two_dim::wh<std::make_signed_t<std::common_type_t<typename will::two_dim::attribute_traits<std::decay_t<T>>::element_type, typename will::two_dim::attribute_traits<std::decay_t<T>>::element_type>>>> operator-(const T& lhs, const U& rhs)noexcept{
using LHS = will::two_dim::attribute_traits<std::decay_t<T>>;
using LHSET = typename LHS::element_type;
using RHS = will::two_dim::attribute_traits<std::decay_t<U>>;
using RHSET = typename RHS::element_type;
using common_t = std::make_signed_t<std::common_type_t<LHSET, RHSET>>;
return will::two_dim::wh<common_t>{static_cast<common_t>(LHS::x(lhs) - RHS::x(rhs)), static_cast<common_t>(LHS::y(lhs) - RHS::y(rhs))};
}
template<typename T, typename U, std::enable_if_t<std::is_same<will::two_dim::tag::size, typename will::two_dim::attribute_traits<std::decay_t<T>>::tag_type>::value && std::is_same<will::two_dim::tag::size, typename will::two_dim::attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr will::two_dim::attribute_proxy<will::two_dim::wh<std::make_signed_t<std::common_type_t<typename will::two_dim::attribute_traits<std::decay_t<T>>::element_type, typename will::two_dim::attribute_traits<std::decay_t<T>>::element_type>>>> operator-(const T& lhs, const U& rhs)noexcept{
using LHS = will::two_dim::attribute_traits<std::decay_t<T>>;
using LHSET = typename LHS::element_type;
using RHS = will::two_dim::attribute_traits<std::decay_t<U>>;
using RHSET = typename RHS::element_type;
using common_t = std::make_signed_t<std::common_type_t<LHSET, RHSET>>;
return will::two_dim::wh<common_t>{static_cast<common_t>(LHS::w(lhs) - RHS::w(rhs)), static_cast<common_t>(LHS::h(lhs) - RHS::h(rhs))};
}
template<typename T, typename U, std::enable_if_t<std::is_same<will::two_dim::tag::point, typename will::two_dim::attribute_traits<std::decay_t<T>>::tag_type>::value && std::is_same<will::two_dim::tag::size, typename will::two_dim::attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr will::two_dim::attribute_proxy<will::two_dim::xy<std::common_type_t<typename will::two_dim::attribute_traits<std::decay_t<T>>::element_type, typename will::two_dim::attribute_traits<std::decay_t<T>>::element_type>>> operator+(const T& lhs, const U& rhs)noexcept{
using LHS = will::two_dim::attribute_traits<std::decay_t<T>>;
using LHSET = typename LHS::element_type;
using RHS = will::two_dim::attribute_traits<std::decay_t<U>>;
using RHSET = typename RHS::element_type;
using common_t = std::common_type_t<LHSET, RHSET>;
return will::two_dim::xy<common_t>{static_cast<common_t>(LHS::x(lhs) + RHS::w(rhs)), static_cast<common_t>(LHS::y(lhs) + RHS::h(rhs))};
}
template<typename T, typename U, std::enable_if_t<std::is_same<will::two_dim::tag::size, typename will::two_dim::attribute_traits<std::decay_t<T>>::tag_type>::value && std::is_same<will::two_dim::tag::point, typename will::two_dim::attribute_traits<std::decay_t<U>>::tag_type>::value, std::nullptr_t> = nullptr>
constexpr will::two_dim::attribute_proxy<will::two_dim::xy<std::common_type_t<typename will::two_dim::attribute_traits<std::decay_t<T>>::element_type, typename will::two_dim::attribute_traits<std::decay_t<T>>::element_type>>> operator+(const T& lhs, const U& rhs)noexcept{
using LHS = will::two_dim::attribute_traits<std::decay_t<T>>;
using LHSET = typename LHS::element_type;
using RHS = will::two_dim::attribute_traits<std::decay_t<U>>;
using RHSET = typename RHS::element_type;
using common_t = std::common_type_t<LHSET, RHSET>;
return will::two_dim::xy<common_t>{static_cast<common_t>(LHS::w(lhs) + RHS::x(rhs)), static_cast<common_t>(LHS::h(lhs) + RHS::y(rhs))};
}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xy<T>& operator*=(will::two_dim::xy<T>& lhs, U&& rhs)noexcept{lhs.x *= rhs; lhs.y *= rhs; return lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xy<T> operator*(will::two_dim::xy<T> lhs, U&& rhs)noexcept{return lhs *= rhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xy<T> operator*(U&& lhs, will::two_dim::xy<T> rhs)noexcept{return rhs *= lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xy<T>& operator/=(will::two_dim::xy<T>& lhs, U&& rhs)noexcept{lhs.x /= rhs; lhs.y /= rhs; return lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xy<T> operator/(will::two_dim::xy<T> lhs, U&& rhs)noexcept{return lhs /= rhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xy<T> operator/(U&& lhs, will::two_dim::xy<T> rhs)noexcept{return rhs /= lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::wh<T>& operator*=(will::two_dim::wh<T>& lhs, U&& rhs)noexcept{lhs.w *= rhs; lhs.h *= rhs; return lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::wh<T> operator*(will::two_dim::wh<T> lhs, U&& rhs)noexcept{return lhs *= rhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::wh<T> operator*(U&& lhs, will::two_dim::wh<T> rhs)noexcept{return rhs *= lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::wh<T>& operator/=(will::two_dim::wh<T>& lhs, U&& rhs)noexcept{lhs.w /= rhs; lhs.h /= rhs; return lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::wh<T> operator/(will::two_dim::wh<T> lhs, U&& rhs)noexcept{return lhs /= rhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::wh<T> operator/(U&& lhs, will::two_dim::wh<T> rhs)noexcept{return rhs /= lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xyxy<T>& operator*=(will::two_dim::xyxy<T>& lhs, U&& rhs)noexcept{lhs._1 *= rhs; lhs._2 *= rhs; return lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xyxy<T> operator*(will::two_dim::xyxy<T> lhs, U&& rhs)noexcept{return lhs *= rhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xyxy<T> operator*(U&& lhs, will::two_dim::xyxy<T> rhs)noexcept{return rhs *= lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xyxy<T>& operator/=(will::two_dim::xyxy<T>& lhs, U&& rhs)noexcept{lhs._1 /= rhs; lhs._2 /= rhs; return lhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xyxy<T> operator/(will::two_dim::xyxy<T> lhs, U&& rhs)noexcept{return lhs /= rhs;}
template<typename T, typename U, std::enable_if_t<std::is_arithmetic<std::decay_t<U>>::value>* = nullptr>
constexpr will::two_dim::xyxy<T> operator/(U&& lhs, will::two_dim::xyxy<T> rhs)noexcept{return rhs /= lhs;}
template<typename T, typename U, typename V, std::enable_if_t<std::is_arithmetic<std::decay_t<V>>::value>* = nullptr>
constexpr will::two_dim::xywh<T, U>& operator*=(will::two_dim::xywh<T, U>& lhs, V&& rhs)noexcept{lhs.xy *= rhs; lhs.wh *= rhs; return lhs;}
template<typename T, typename U, typename V, std::enable_if_t<std::is_arithmetic<std::decay_t<V>>::value>* = nullptr>
constexpr will::two_dim::xywh<T, U> operator*(will::two_dim::xywh<T, U> lhs, V&& rhs)noexcept{return lhs *= rhs;}
template<typename T, typename U, typename V, std::enable_if_t<std::is_arithmetic<std::decay_t<V>>::value>* = nullptr>
constexpr will::two_dim::xywh<T, U> operator*(V&& lhs, will::two_dim::xywh<T, U> rhs)noexcept{return rhs *= lhs;}
template<typename T, typename U, typename V, std::enable_if_t<std::is_arithmetic<std::decay_t<V>>::value>* = nullptr>
constexpr will::two_dim::xywh<T, U>& operator/=(will::two_dim::xywh<T, U>& lhs, V&& rhs)noexcept{lhs.xy /= rhs; lhs.wh /= rhs; return lhs;}
template<typename T, typename U, typename V, std::enable_if_t<std::is_arithmetic<std::decay_t<V>>::value>* = nullptr>
constexpr will::two_dim::xywh<T, U> operator/(will::two_dim::xywh<T, U> lhs, V&& rhs)noexcept{return lhs /= rhs;}
template<typename T, typename U, typename V, std::enable_if_t<std::is_arithmetic<std::decay_t<V>>::value>* = nullptr>
constexpr will::two_dim::xywh<T, U> operator/(V&& lhs, will::two_dim::xywh<T, U> rhs)noexcept{return rhs /= lhs;}