Skip to content

Commit

Permalink
feat: for later
Browse files Browse the repository at this point in the history
  • Loading branch information
qudix committed Oct 8, 2024
1 parent a8938b9 commit 524e59e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/REL/Relocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ namespace REL
inline constexpr std::uint8_t RET = 0xC3;
inline constexpr std::uint8_t INT3 = 0xCC;

template <class T, class U>
[[nodiscard]] auto AdjustPointer(U* a_ptr, const std::ptrdiff_t a_adjust) noexcept
{
auto addr = a_ptr ? reinterpret_cast<std::uintptr_t>(a_ptr) + a_adjust : 0;
if constexpr (std::is_const_v<U> && std::is_volatile_v<U>) {
return reinterpret_cast<std::add_cv_t<T>*>(addr);
} else if constexpr (std::is_const_v<U>) {
return reinterpret_cast<std::add_const_t<T>*>(addr);
} else if constexpr (std::is_volatile_v<U>) {
return reinterpret_cast<std::add_volatile_t<T>*>(addr);
} else {
return reinterpret_cast<T*>(addr);
}
}

template <class F, class... Args>
constexpr std::invoke_result_t<F, Args...> invoke(F&& a_func, Args&&... a_args) //
noexcept(std::is_nothrow_invocable_v<F, Args...>)
Expand Down

0 comments on commit 524e59e

Please sign in to comment.