Skip to content

Commit

Permalink
Use spaceship operator for Pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
visuve committed Mar 20, 2024
1 parent 744c3d3 commit acc1ef5
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions HackLib/Pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,29 +120,19 @@ class Pointer
return _internal.Value == other._internal.Value;
}

constexpr bool operator != (const Pointer& other) const
constexpr auto operator <=> (const Pointer& other) const
{
return _internal.Value != other._internal.Value;
return _internal.Value <=> other._internal.Value;
}

constexpr bool operator < (const Pointer& other) const
constexpr bool operator == (size_t offset) const
{
return _internal.Value < other._internal.Value;
return _internal.Value == offset;
}

constexpr bool operator > (const Pointer& other) const
constexpr auto operator <=> (size_t offset) const
{
return _internal.Value > other._internal.Value;
}

constexpr bool operator < (size_t offset) const
{
return _internal.Value < offset;
}

constexpr bool operator > (size_t offset) const
{
return _internal.Value > offset;
return _internal.Value <=> offset;
}

inline const uint8_t* Value() const
Expand Down Expand Up @@ -215,11 +205,14 @@ struct std::formatter<Pointer>

auto format(const Pointer& p, std::format_context& ctx) const
{
#ifdef _WIN64
return std::format_to(ctx.out(), "0x{:016X}", p._internal.Value);
#else
return std::format_to(ctx.out(), "0x{:08X}", p._internal.Value);
#endif
if constexpr (Pointer::Size == 8)
{
return std::format_to(ctx.out(), "0x{:016X}", p._internal.Value);
}
else
{
return std::format_to(ctx.out(), "0x{:08X}", p._internal.Value);
}
}
};

Expand Down

0 comments on commit acc1ef5

Please sign in to comment.