CS2-Kit
C++23 library for CS2 Metamod:Source plugin development
Loading...
Searching...
No Matches
VirtualCall.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
5
namespace
CS2Kit::Sdk
6
{
7
8
/**
9
* Call a virtual function by vtable index on a given object.
10
*/
11
template
<
typename
Ret,
typename
... Args>
12
constexpr
Ret
CallVirtual
(
int
index,
void
* thisPtr, Args... args)
noexcept
13
{
14
auto
vtable = *
reinterpret_cast<
void
***
>
(thisPtr);
15
auto
fn =
reinterpret_cast<
Ret (*)(
void
*, Args...)
>
(vtable[index]);
16
return
fn(thisPtr, args...);
17
}
18
19
}
// namespace CS2Kit::Sdk
CS2Kit::Sdk
Definition
ChatInputCapture.cpp:7
CS2Kit::Sdk::CallVirtual
constexpr Ret CallVirtual(int index, void *thisPtr, Args... args) noexcept
Definition
VirtualCall.hpp:12
src
Sdk
VirtualCall.hpp
Generated by
1.9.8