diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-18 23:42:07 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-18 23:42:07 +0100 |
commit | 4d9a82b720c8ce74b94f43f72ddd819ef21abbdf (patch) | |
tree | c0a5d21b8e19fbb60c286faec8e302e6f32b6679 /src/local-coords.hpp | |
parent | 32b8c22828315292857e2cd9909fba620f30ff70 (diff) |
pre-declare integer types without cstddef/cstdint
Diffstat (limited to 'src/local-coords.hpp')
-rw-r--r-- | src/local-coords.hpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/local-coords.hpp b/src/local-coords.hpp index eef511d6..cb7a5c24 100644 --- a/src/local-coords.hpp +++ b/src/local-coords.hpp @@ -8,32 +8,32 @@ namespace floormat { struct local_coords final { - std::uint8_t x : 4 = 0, y : 4 = 0; - explicit constexpr local_coords(std::size_t idx) noexcept; + uint8_t x : 4 = 0, y : 4 = 0; + explicit constexpr local_coords(size_t idx) noexcept; constexpr local_coords() noexcept = default; - template<typename T> requires (std::is_integral_v<T> && sizeof(T) <= sizeof(std::size_t)) + template<typename T> requires (std::is_integral_v<T> && sizeof(T) <= sizeof(size_t)) constexpr local_coords(T x, T y) noexcept; - constexpr local_coords(std::uint8_t x, std::uint8_t y) noexcept : x{x}, y{y} {} - constexpr std::uint8_t to_index() const noexcept { return y*TILE_MAX_DIM + x; } + constexpr local_coords(uint8_t x, uint8_t y) noexcept : x{x}, y{y} {} + constexpr uint8_t to_index() const noexcept { return y*TILE_MAX_DIM + x; } constexpr bool operator==(const local_coords&) const noexcept = default; template<typename T> explicit constexpr operator Math::Vector2<T>() const noexcept { return Math::Vector2<T>(T(x), T(y)); } template<typename T> explicit constexpr operator Math::Vector3<T>() const noexcept { return Math::Vector3<T>(T(x), T(y), T(0)); } }; -constexpr local_coords::local_coords(std::size_t index) noexcept : - x{(std::uint8_t)(index % TILE_MAX_DIM)}, - y{(std::uint8_t)(index / TILE_MAX_DIM)} +constexpr local_coords::local_coords(size_t index) noexcept : + x{(uint8_t)(index % TILE_MAX_DIM)}, + y{(uint8_t)(index / TILE_MAX_DIM)} { fm_assert(index < TILE_COUNT); } template<typename T> -requires (std::is_integral_v<T> && sizeof(T) <= sizeof(std::size_t)) +requires (std::is_integral_v<T> && sizeof(T) <= sizeof(size_t)) constexpr local_coords::local_coords(T x, T y) noexcept - : x{(std::uint8_t)x}, y{(std::uint8_t)y} + : x{(uint8_t)x}, y{(uint8_t)y} { - fm_assert((std::size_t)x < TILE_MAX_DIM && (std::size_t)y < TILE_MAX_DIM); + fm_assert((size_t)x < TILE_MAX_DIM && (size_t)y < TILE_MAX_DIM); } } // namespace floormat |