Vector2.hpp
Go to the documentation of this file.
1 #ifndef _QUORI_FACE_VECTOR2_HPP_
2 #define _QUORI_FACE_VECTOR2_HPP_
3 
4 #include <cstdint>
5 #include <iostream>
6 
7 namespace quori_face
8 {
15  template<typename T>
16  struct Vector2
17  {
23  : x(T())
24  , y(T())
25  {
26  }
27 
31  Vector2(const T x, const T y)
32  : x(x)
33  , y(y)
34  {
35  }
36 
37  T x;
38  T y;
39 
40  bool operator ==(const Vector2<T> &other) const noexcept
41  {
42  return x == other.x && y == other.y;
43  }
44 
45  bool operator !=(const Vector2<T> &other) const noexcept
46  {
47  return x != other.x || y != other.y;
48  }
49 
50  Vector2<T> operator -(const Vector2<T> &rhs) const noexcept
51  {
52  return Vector2<T>(x - rhs.x, y - rhs.y);
53  }
54 
55  Vector2<T> &operator -=(const Vector2<T> &rhs) noexcept
56  {
57  x -= rhs.x;
58  y -= rhs.y;
59  return *this;
60  }
61 
62  Vector2<T> operator +(const Vector2<T> &rhs) const noexcept
63  {
64  return Vector2<T>(x + rhs.x, y + rhs.y);
65  }
66 
67  Vector2<T> &operator +=(const Vector2<T> &rhs) noexcept
68  {
69  x += rhs.x;
70  y += rhs.y;
71  return *this;
72  }
73 
74  Vector2<T> operator *(const Vector2<T> &rhs) noexcept
75  {
76  return Vector2<T>(x * rhs.x, y * rhs.y);
77  }
78 
79  Vector2<T> &operator *=(const Vector2<T> &rhs) noexcept
80  {
81  x *= rhs.x;
82  y *= rhs.y;
83  return *this;
84  }
85 
86  Vector2<T> operator /(const Vector2<T> &rhs) noexcept
87  {
88  return Vector2<T>(x / rhs.x, y / rhs.y);
89  }
90 
91  Vector2<T> &operator /=(const Vector2<T> &rhs) noexcept
92  {
93  x /= rhs.x;
94  y /= rhs.y;
95  return *this;
96  }
97  };
98 }
99 
100 template<typename T>
101 std::ostream &operator <<(std::ostream &o, const quori_face::Vector2<T> &value)
102 {
103  return o << "<" << value.x << ", " << value.y << ">";
104 }
105 
106 #endif
quori_face::Vector2::operator*=
Vector2< T > & operator*=(const Vector2< T > &rhs) noexcept
Definition: Vector2.hpp:79
quori_face::Vector2
Definition: Vector2.hpp:16
y
GLint y
Definition: glcorearb.h:251
quori_face::Vector2::Vector2
Vector2()
Construct a zero'd Vector2.
Definition: Vector2.hpp:22
quori_face::Vector2::x
T x
Definition: Vector2.hpp:37
quori_face::Vector2::operator==
bool operator==(const Vector2< T > &other) const noexcept
Definition: Vector2.hpp:40
quori_face::Vector2::operator/=
Vector2< T > & operator/=(const Vector2< T > &rhs) noexcept
Definition: Vector2.hpp:91
quori_face::Vector2::operator-=
Vector2< T > & operator-=(const Vector2< T > &rhs) noexcept
Definition: Vector2.hpp:55
quori_face::Vector2::operator+
Vector2< T > operator+(const Vector2< T > &rhs) const noexcept
Definition: Vector2.hpp:62
value
GLsizei const GLfloat * value
Definition: glcorearb.h:800
quori_face::Vector2::y
T y
Definition: Vector2.hpp:38
quori_face::Vector2::operator!=
bool operator!=(const Vector2< T > &other) const noexcept
Definition: Vector2.hpp:45
quori_face::Vector2::operator/
Vector2< T > operator/(const Vector2< T > &rhs) noexcept
Definition: Vector2.hpp:86
quori_face
Definition: Cache.hpp:9
quori_face::Vector2::Vector2
Vector2(const T x, const T y)
Definition: Vector2.hpp:31
quori_face::Vector2::operator+=
Vector2< T > & operator+=(const Vector2< T > &rhs) noexcept
Definition: Vector2.hpp:67
quori_face::Vector2::operator-
Vector2< T > operator-(const Vector2< T > &rhs) const noexcept
Definition: Vector2.hpp:50
quori_face::Vector2::operator*
Vector2< T > operator*(const Vector2< T > &rhs) noexcept
Definition: Vector2.hpp:74
x
GLint GLenum GLint x
Definition: glcorearb.h:384
operator<<
std::ostream & operator<<(std::ostream &o, const quori_face::Vector2< T > &value)
Definition: Vector2.hpp:101


quori_face
Author(s):
autogenerated on Wed Mar 2 2022 00:53:20