4#ifndef LODESTONE_VEC2I_H
5#define LODESTONE_VEC2I_H
13 static_assert(std::is_arithmetic_v<T>,
"typeof T must be numeric");
17 constexpr Vec2(
const T
x,
const T z) :
x(
x),
y(z) {}
20 explicit constexpr Vec2(
const Vec2<O>& rhs) :
x(static_cast<T>(rhs.
x)),
y(static_cast<T>(rhs.
y)) {
25 constexpr operator T *() {
return &
x; }
26 constexpr operator const T *()
const {
return &
x; }
29 return x == rhs.
x &&
y == rhs.
y;
41 return {
x + rhs.
x,
y + rhs.
y};
45 return {
x - rhs.
x,
y - rhs.
y};
49 return {
x * rhs.
x,
y * rhs.
y};
53 return {
x / rhs.
x,
y / rhs.
y};
57 return std::format(
"Vec2[x={}, y={}]",
x,
y);
72template <
typename T>
struct std::hash<
lodestone::level::types::Vec2<T>> {
75 return std::hash<T>()(v.x) ^ (std::hash<T>()(v.y) << 1);
80struct std::formatter<
lodestone::level::types::Vec2<T>> {
81 template <
typename FormatParseContext>
constexpr auto parse(FormatParseContext &pc) {
return pc.begin(); }
constexpr Vec2< T > VEC2_ZERO
Definition Vec2.h:62
Vec2< float > Vec2f
Definition Vec2.h:68
Vec2< int > Vec2i
Definition Vec2.h:67
constexpr Vec2< T > VEC2_ONE
Definition Vec2.h:65
Vec2< double > Vec2d
Definition Vec2.h:69
constexpr Vec2 operator/(const Vec2 &rhs) const
Definition Vec2.h:52
constexpr Vec2 operator+(const T v) const
Definition Vec2.h:32
constexpr Vec2 operator-(const T v) const
Definition Vec2.h:34
constexpr Vec2 operator/(const T v) const
Definition Vec2.h:38
std::string toString() const
Definition Vec2.h:56
constexpr Vec2 operator*(const T v) const
Definition Vec2.h:36
int x
Definition Vec2.h:15
constexpr ~Vec2()=default
constexpr Vec2 operator-(const Vec2 &rhs) const
Definition Vec2.h:44
constexpr Vec2(const T x, const T z)
Definition Vec2.h:17
constexpr Vec2(const Vec2< O > &rhs)
Definition Vec2.h:20
constexpr bool operator==(const Vec2 &rhs) const
Definition Vec2.h:28
constexpr Vec2 operator*(const Vec2 &rhs) const
Definition Vec2.h:48
constexpr Vec2 operator+(const Vec2 &rhs) const
Definition Vec2.h:40
size_t operator()(const lodestone::level::types::Vec2< T > &v) const noexcept
Definition Vec2.h:74