- In commit b3facaa6bb, the copyright header was
updated to include "Citron Homebrew Project" across multiple files, regardless
of whether any contributions were made.
- This commit removes the incorrect attribution and reverts the copyright header
to its previous state.
- Copyright attribution should only be added when meaningful contributions have
been made to the file.
- This commit ensures proper compliance with copyright standards and maintains
correct attribution to the respective contributors.
- Special thanks to Tachi for pointing out the need for these corrections and
ensuring that proper attribution practices are followed.
56 lines
3.3 KiB
C++
56 lines
3.3 KiB
C++
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <type_traits>
|
|
|
|
namespace Common {
|
|
|
|
// Represents a point within a 2D space.
|
|
template <typename T>
|
|
struct Point {
|
|
static_assert(std::is_arithmetic_v<T>, "T must be an arithmetic type!");
|
|
|
|
T x{};
|
|
T y{};
|
|
|
|
#define ARITHMETIC_OP(op, compound_op) \
|
|
friend constexpr Point operator op(const Point& lhs, const Point& rhs) noexcept { \
|
|
return { \
|
|
.x = static_cast<T>(lhs.x op rhs.x), \
|
|
.y = static_cast<T>(lhs.y op rhs.y), \
|
|
}; \
|
|
} \
|
|
friend constexpr Point operator op(const Point& lhs, T value) noexcept { \
|
|
return { \
|
|
.x = static_cast<T>(lhs.x op value), \
|
|
.y = static_cast<T>(lhs.y op value), \
|
|
}; \
|
|
} \
|
|
friend constexpr Point operator op(T value, const Point& rhs) noexcept { \
|
|
return { \
|
|
.x = static_cast<T>(value op rhs.x), \
|
|
.y = static_cast<T>(value op rhs.y), \
|
|
}; \
|
|
} \
|
|
friend constexpr Point& operator compound_op(Point& lhs, const Point& rhs) noexcept { \
|
|
lhs.x = static_cast<T>(lhs.x op rhs.x); \
|
|
lhs.y = static_cast<T>(lhs.y op rhs.y); \
|
|
return lhs; \
|
|
} \
|
|
friend constexpr Point& operator compound_op(Point& lhs, T value) noexcept { \
|
|
lhs.x = static_cast<T>(lhs.x op value); \
|
|
lhs.y = static_cast<T>(lhs.y op value); \
|
|
return lhs; \
|
|
}
|
|
ARITHMETIC_OP(+, +=)
|
|
ARITHMETIC_OP(-, -=)
|
|
ARITHMETIC_OP(*, *=)
|
|
ARITHMETIC_OP(/, /=)
|
|
#undef ARITHMETIC_OP
|
|
|
|
friend constexpr bool operator==(const Point&, const Point&) = default;
|
|
};
|
|
|
|
} // namespace Common
|