template<typename T1, typename T2 = T1>
numeric::Vector2 class

Vector2.

Constructors, destructors, conversion operators

Vector2() constexpr
Construct a new Vector2 object.
Vector2(T1 x, T2 y) constexpr noexcept
Construct a new Vector2 object.
template<typename U1, typename U2>
Vector2(const Vector2<U1, U2>& other) explicit constexpr
Construct a new Vector2 object.

Public functions

auto x() const noexcept -> const T1 & -> auto constexpr
auto y() const noexcept -> const T2 & -> auto constexpr
template<typename U1, typename U2>
auto dot(const Vector2<U1, U2>& other) const -> double -> auto constexpr
template<typename U1, typename U2>
auto cross(const Vector2<U1, U2>& other) const -> double -> auto constexpr

Public variables

T1 _x
T2 _y

Arithmetic operators

definie +, -, *, /, +=, -=, *=, /=, etc.

auto operator-() const -> Vector2< T1, T2 > -> auto constexpr
template<typename U1, typename U2>
auto operator+=(const Vector2<U1, U2>& other) -> Vector2< T1, T2 > & -> CONSTEXPR14 auto
template<typename U1, typename U2>
auto operator-=(const Vector2<U1, U2>& other) -> Vector2< T1, T2 > & -> CONSTEXPR14 auto
template<typename R>
auto operator*=(const R& alpha) -> Vector2< T1, T2 > & -> CONSTEXPR14 auto
template<typename R>
auto operator/=(const R& alpha) -> Vector2< T1, T2 > & -> CONSTEXPR14 auto
template<typename U1, typename U2>
auto operator+(Vector2<T1, T2> x, const Vector2<U1, U2>& y) -> Vector2< T1, T2 > -> friend auto constexpr
template<typename U1, typename U2>
auto operator-(Vector2<T1, T2> x, const Vector2<U1, U2>& y) -> Vector2< T1, T2 > -> friend auto constexpr
template<typename R>
auto operator*(Vector2<T1, T2> x, const R& alpha) -> Vector2< T1, T2 > -> friend auto constexpr
template<typename R>
auto operator*(const R& alpha, Vector2<T1, T2> x) -> Vector2< T1, T2 > -> friend auto constexpr
template<typename R>
auto operator/(Vector2<T1, T2> x, const R& alpha) -> Vector2< T1, T2 > -> friend auto constexpr

Friends

template<class Stream>
auto operator<<(Stream& out, const Vector2<T1, T2>& vec) -> Stream & -> auto

Function documentation

template<typename T1, typename T2>
numeric::Vector2<T1, T2>::Vector2() constexpr

Construct a new Vector2 object.

The function is a constructor for a Vector2 object that initializes its x and y values to 0.

template<typename T1, typename T2>
numeric::Vector2<T1, T2>::Vector2(T1 x, T2 y) constexpr noexcept

Construct a new Vector2 object.

Parameters
in The parameter x is of type T1&&, which means it is a forwarding reference. It can accept any type, and it is passed as an rvalue reference. This allows the constructor to efficiently move or forward the value of x into the _x member variable.
in The parameter "y" is the y-coordinate of the Vector2 object. It represents the vertical position of the vector in a 2D coordinate system.

The function constructs a new Vector2 object with given x and y values.

template<typename T1, typename T2> template<typename U1, typename U2>
numeric::Vector2<T1, T2>::Vector2(const Vector2<U1, U2>& other) explicit constexpr

Construct a new Vector2 object.

Template parameters
U1
U2
Parameters
other in The parameter "other" is a reference to another Vector2 object.

The function constructs a new Vector2 object with given x and y values.

Construct a new Vector2 object

The function constructs a new Vector2 object by copying the values from another Vector2 object.

template<typename T1, typename T2>
auto numeric::Vector2<T1, T2>::x() const noexcept -> const T1 & constexpr

Returns a reference to a constant object of type T1.

The function returns a reference to a constant value of type T1.

template<typename T1, typename T2>
auto numeric::Vector2<T1, T2>::y() const noexcept -> const T2 & constexpr

Returns a reference to a constant object of type T2.

The function y() returns a reference to a constant value of type T2.

template<typename T1, typename T2> template<typename U1, typename U2>
auto numeric::Vector2<T1, T2>::dot(const Vector2<U1, U2>& other) const -> double constexpr

Template parameters
U1
U2
Parameters
other in The parameter "other" is a reference to an object of type Vector2<U1, U2>.
Returns The dot function is returning the dot product of two vectors, which is a scalar value of type double.

The dot function calculates the dot product of two 2D vectors.

template<typename T1, typename T2> template<typename U1, typename U2>
auto numeric::Vector2<T1, T2>::cross(const Vector2<U1, U2>& other) const -> double constexpr

Template parameters
U1
U2
Parameters
other in The parameter "other" is a reference to an object of type Vector2<U1, U2>.
Returns The function cross returns the result of the cross product between the current vector and the other vector. The result is of type double.

The cross product of two 2D vectors is calculated by multiplying their x and y components and subtracting the result.

template<typename T1, typename T2>
auto numeric::Vector2<T1, T2>::operator-() const -> Vector2< T1, T2 > constexpr

Returns The operator- function returns a Vector2 object with the negated values of _x and _y.

The above function negates a Vector2 object.

template<typename T1, typename T2> template<typename U1, typename U2>
CONSTEXPR14 auto numeric::Vector2<T1, T2>::operator+=(const Vector2<U1, U2>& other) -> Vector2< T1, T2 > &

Template parameters
U1
U2
Parameters
other in The parameter "other" is a reference to an object of type Vector2<U1, U2>.
Returns a reference to a Vector2 object.

The function operator+= adds the components of another Vector2 object to the current Vector2 object and returns a reference to the updated object.

template<typename T1, typename T2> template<typename U1, typename U2>
CONSTEXPR14 auto numeric::Vector2<T1, T2>::operator-=(const Vector2<U1, U2>& other) -> Vector2< T1, T2 > &

Template parameters
U1
U2
Parameters
other in The parameter "other" is a reference to an object of type Vector2<U1, U2>.
Returns a reference to a Vector2 object.

The function subtracts the x and y components of another Vector2 object from the current Vector2 object.

template<typename T1, typename T2> template<typename R>
CONSTEXPR14 auto numeric::Vector2<T1, T2>::operator*=(const R& alpha) -> Vector2< T1, T2 > &

Template parameters
R
Parameters
alpha in alpha is a constant reference to a variable of type R.
Returns The operator*= function returns a reference to the modified Vector2 object.

The function multiplies the x and y components of a Vector2 object by a given value.

template<typename T1, typename T2> template<typename R>
CONSTEXPR14 auto numeric::Vector2<T1, T2>::operator/=(const R& alpha) -> Vector2< T1, T2 > &

Template parameters
R
Parameters
alpha in The parameter "alpha" is of type R, which is a template parameter. It represents the value by which the x and y components of the Vector2 object are divided.
Returns a reference to the current instance of the Vector2 class.

The function divides the x and y components of a Vector2 object by a given value.

template<typename T1, typename T2> template<typename U1, typename U2>
friend auto numeric::Vector2<T1, T2>::operator+(Vector2<T1, T2> x, const Vector2<U1, U2>& y) -> Vector2< T1, T2 > constexpr

Template parameters
U1
U2
Parameters
in A Vector2 object with template types T1 and T2.
in The parameter y is a constant reference to a Vector2 object with template parameters U1 and U2.
Returns a Vector2 object.

The above function is a friend function that adds two Vector2 objects and returns the result.

template<typename T1, typename T2> template<typename U1, typename U2>
friend auto numeric::Vector2<T1, T2>::operator-(Vector2<T1, T2> x, const Vector2<U1, U2>& y) -> Vector2< T1, T2 > constexpr

Template parameters
U1
U2
Parameters
in A Vector2 object with template types T1 and T2.
in The parameter y is a constant reference to a Vector2 object with template parameters U1 and U2.
Returns a Vector2 object.

The function is a friend function that subtracts two Vector2 objects and returns the result.

template<typename T1, typename T2> template<typename R>
friend auto numeric::Vector2<T1, T2>::operator*(Vector2<T1, T2> x, const R& alpha) -> Vector2< T1, T2 > constexpr

Template parameters
R
Parameters
in A Vector2 object of type T1 and T2.
alpha in The parameter alpha is a scalar value that will be used to multiply each component of the Vector2 object x.
Returns a Vector2 object.

The function multiplies a Vector2 object by a scalar value.

template<typename T1, typename T2> template<typename R>
friend auto numeric::Vector2<T1, T2>::operator*(const R& alpha, Vector2<T1, T2> x) -> Vector2< T1, T2 > constexpr

Template parameters
R
Parameters
alpha in The parameter alpha is a scalar value that will be multiplied with the vector x.
in A Vector2 object of type T1 and T2.
Returns a Vector2 object.

The above function multiplies a Vector2 object by a scalar value.

template<typename T1, typename T2> template<typename R>
friend auto numeric::Vector2<T1, T2>::operator/(Vector2<T1, T2> x, const R& alpha) -> Vector2< T1, T2 > constexpr

Template parameters
R
Parameters
in A Vector2 object of type T1 and T2.
alpha in The parameter alpha is a scalar value that is used to divide each component of the Vector2 object x.
Returns a Vector2 object.

The above function divides a Vector2 object by a scalar value.

template<typename T1, typename T2> template<class Stream>
auto operator<<(Stream& out, const Vector2<T1, T2>& vec) -> Stream &

Template parameters
Stream
Parameters
out out The parameter "out" is a reference to a Stream object. It is used to output the contents of the Vector2 object to the stream.
vec in The parameter vec is a constant reference to an object of type Vector2<T1, T2>.
Returns The return type of the operator<< function is Stream&.

The above function overloads the << operator to output a Vector2 object in the format "{x, y}".