tmxlite: D:/W/B/src/tmxlite-1.4.5/tmxlite/include/tmxlite/Types.inl Source File

tmxlite 1.0.0 lightweight parse for Tiled maps

Types.inl
1/*********************************************************************
2Matt Marchant 2016 - 2023
3http://trederia.blogspot.com
4
5tmxlite - Zlib license.
6
7This software is provided 'as-is', without any express or
8implied warranty. In no event will the authors be held
9liable for any damages arising from the use of this software.
10
11Permission is granted to anyone to use this software for any purpose,
12including commercial applications, and to alter it and redistribute
13it freely, subject to the following restrictions:
14
151. The origin of this software must not be misrepresented;
16you must not claim that you wrote the original software.
17If you use this software in a product, an acknowledgment
18in the product documentation would be appreciated but
19is not required.
20
212. Altered source versions must be plainly marked as such,
22and must not be misrepresented as being the original software.
23
243. This notice may not be removed or altered from any
25source distribution.
26*********************************************************************/
27
28template <typename T>
29Vector2<T> operator + (const Vector2<T>& l, const Vector2<T>& r)
30{
31 return { l.x + r.x, l.y + r.y };
32}
33
34template <typename T>
35Vector2<T>& operator += (Vector2<T>& l, const Vector2<T>& r)
36{
37 l.x += r.x;
38 l.y += r.y;
39 return l;
40}
41
42template <typename T>
43Vector2<T> operator - (const Vector2<T>& l, const Vector2<T>& r)
44{
45 return { l.x - r.x, l.y - r.y };
46}
47
48template <typename T>
49Vector2<T>& operator -= (Vector2<T>& l, const Vector2<T>& r)
50{
51 l.x -= r.x;
52 l.y -= r.y;
53 return l;
54}
55
56template <typename T>
57Vector2<T> operator * (const Vector2<T>& l, const Vector2<T>& r)
58{
59 return { l.x * r.x, l.y * r.y };
60}
61
62template <typename T>
63Vector2<T>& operator *= (Vector2<T>& l, const Vector2<T>& r)
64{
65 l.x *= r.x;
66 l.y *= r.y;
67 return l;
68}
69
70template <typename T>
71Vector2<T> operator * (const Vector2<T>& l, T r)
72{
73 return { l.x * r, l.y * r };
74}
75
76template <typename T>
77Vector2<T>& operator *= (Vector2<T>& l, T r)
78{
79 l.x *= r;
80 l.y *= r;
81 return l;
82}
83
84template <typename T>
85Vector2<T> operator / (const Vector2<T>& l, const Vector2<T>& r)
86{
87 return { l.x / r.x, l.y / r.y };
88}
89
90template <typename T>
91Vector2<T>& operator /= (Vector2<T>& l, const Vector2<T>& r)
92{
93 l.x /= r.x;
94 l.y /= r.y;
95 return l;
96}
97
98template <typename T>
99Vector2<T> operator / (const Vector2<T>& l, T r)
100{
101 return { l.x / r, l.y / r };
102}
103
104template <typename T>
105Vector2<T>& operator /= (Vector2<T>& l, T r)
106{
107 l.x /= r;
108 l.y /= r;
109 return l;
110}