13#pragma warning(disable : 4201)
23 template <Primitive T>
27 static constexpr size_t size = 2;
30 explicit constexpr rvec(T a, T b) : x{ a }, y{ b } {}
33 explicit constexpr rvec(V &other)
requires(V::size >= size) : x{ other.x }, y{ other.y } {}
36 explicit constexpr rvec(V
const &other)
requires(V::size >= size && std::is_const_v<typename V::type>) : x{ other.x }, y{ other.y } {}
44 constexpr void reset() noexcept;
48 constexpr
rvec<size, T> &operator=(
rvec<size, U> const &b)
50 for (
size_t i = 0; i < size; i++)
48 constexpr
rvec<size, T> &operator=(
rvec<size, U> const &b) {
…}
60 for (
size_t i = 0; i < size; i++)
71 [[nodiscard]] constexpr
vec<2, T> operator-() const noexcept;
75 constexpr
rvec<2, T> &operator+=(U const value) noexcept;
77 constexpr
rvec<2, T> &operator-=(U const value) noexcept;
79 constexpr
rvec<2, T> &operator*=(U const value) noexcept;
81 constexpr
rvec<2, T> &operator/=(U const value) noexcept;
83 constexpr
rvec<2, T> &operator%=(U const value) noexcept;
85 constexpr
rvec<2, T> &operator+=(U const &other) noexcept requires(size == U::size);
87 constexpr
rvec<2, T> &operator-=(U const &other) noexcept requires(size == U::size);
89 constexpr
rvec<2, T> &operator*=(U const &other) noexcept requires(size == U::size);
91 constexpr
rvec<2, T> &operator/=(U const &other) noexcept requires(size == U::size);
93 constexpr
rvec<2, T> &operator%=(U const &other) noexcept requires(size == U::size);
96 [[nodiscard]] constexpr T &operator[](
size_t i);
98 [[nodiscard]] constexpr T const &operator[](
size_t i) const;
116 std::array<_detail::primitive_reference_wrapper<T>, 2>
data;
Reference wrapper for primitives which does not allow rebinding after instantiation.
Concept to determine if a type is any kind of vector.
Concept that ensures a type is either floating point or integral.
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 rvec(V const &other)
Templated constructor from another vector type (const version).
static constexpr rvec< 2, T > from_vec(U const &other)
Templated factory method to create an rvec<2, T> from another vector type (const version).
constexpr rvec< size, T > & operator=(vec< size, U > const &b)
Assignment operator from a vec of same size.
_detail::primitive_reference_wrapper< T > r
constexpr rvec(V &other)
Templated constructor from another vector type (non-const version).
static constexpr rvec< 2, T > from_vec(U &other)
Templated factory method to create an rvec<2, T> from another vector type (non-const version).
std::array< _detail::primitive_reference_wrapper< T >, 2 > data
Array access to the elements.
constexpr rvec(T a, T b)
Constructor from two primitive values.
T type
The underlying primitive type.
_detail::primitive_reference_wrapper< T > g
Internal detail definition of a reference vector with fixed size L and type T
Definition of the mathematical vector with fixed size L and type T
std::array< T, size > data
The underlying data of the vector.