14#pragma warning(disable : 4201)
21 template <Primitive T>
24 static_assert(!std::is_const_v<T>);
26 static constexpr size_t size = 2;
28 constexpr vec() =
default;
30 template <Primitive U>
31 constexpr vec(U value);
33 template <Primitive A, Primitive B>
34 constexpr vec(A a, B b);
36 template <
typename... U>
39 constexpr vec(std::array<T, size>
const &arr) :
data{ arr } {}
41 constexpr vec(std::array<T, size> &&arr) :
data{
std::move(arr) } {}
45 constexpr void reset() noexcept;
49 constexpr
vec<
size, T> &operator=(_detail::rvec<
size, U> const &b)
51 for (
size_t i = 0; i <
size; i++)
49 constexpr
vec<
size, T> &operator=(_detail::rvec<
size, U> const &b) {
…}
61 for (
size_t i = 0; i <
size; i++)
71 [[nodiscard]] constexpr
vec<2, T> operator-() const noexcept;
74 constexpr
vec<2, T> &operator+=(U const value) noexcept;
76 constexpr
vec<2, T> &operator-=(U const value) noexcept;
78 constexpr
vec<2, T> &operator*=(U const value) noexcept;
80 constexpr
vec<2, T> &operator/=(U const value) noexcept;
82 constexpr
vec<2, T> &operator%=(U const value) noexcept;
84 constexpr
vec<2, T> &operator+=(U const &other) noexcept requires(
size == U::
size);
86 constexpr
vec<2, T> &operator-=(U const &other) noexcept requires(
size == U::
size);
88 constexpr
vec<2, T> &operator*=(U const &other) noexcept requires(
size == U::
size);
90 constexpr
vec<2, T> &operator/=(U const &other) noexcept requires(
size == U::
size);
92 constexpr
vec<2, T> &operator%=(U const &other) noexcept requires(
size == U::
size);
95 [[nodiscard]] constexpr T &operator[](
size_t i);
97 [[nodiscard]] constexpr T const &operator[](
size_t i) const;
114 static_assert(
sizeof(
data) == 2 *
sizeof(T));
122 template <Primitive _>
136 template <
typename A,
typename B,
typename... C>
146 template <Primitive U>
164 template <
typename A,
typename B,
typename... C>
165 constexpr void unpack_data(
size_t offset, A a, B b, C... c);
Concept to determine if a type is any kind of vector.
Concept that ensures a type is either floating point or integral.
Contains mathematical utility functions and classes.
constexpr mat< T::size.x, T::size.y, std::remove_const_t< typename T::type > > operator+(U const left, T const &right)
Adds a matrix to a primitive.
constexpr vec(std::array< T, size > &&arr)
Constructs a vec by moving data from a given array.
static constexpr vec< 2, T > zero() noexcept
Returns a new zero-initialized vec.
constexpr vec< size, T > & operator=(vec< size, U > const &b)
Assignment operator from another vec.
constexpr void unpack_data(size_t offset, V vec)
Unpacks a vector into the matrix data.
static constexpr size_t get_parameter_pack_size()
Determines the size of a parameter pack for vector types.
std::array< T, 2 > data
Array access to the elements.
T type
Type of the vector's components.
constexpr vec()=default
Default constructor.
constexpr vec(std::array< T, size > const &arr)
Constructs a vec from a given array.
Definition of the mathematical vector with fixed size L and type T
std::array< T, size > data
The underlying data of the vector.
static constexpr size_t get_parameter_pack_size()
Determines the size of a parameter pack for primitive types.
constexpr void unpack_data(size_t offset, U u)
Unpacks a single primitive value into the vector data.
static constexpr size_t size
Number of elements in the vector.
constexpr vec()=default
Default constructor.
constexpr void reset() noexcept
Resets the vector to the zero vector.