Skip to content

Instantly share code, notes, and snippets.

@Eczbek
Created March 3, 2025 22:13
Show Gist options
  • Save Eczbek/cecec131d18cec89fbe0c9393546476f to your computer and use it in GitHub Desktop.
Save Eczbek/cecec131d18cec89fbe0c9393546476f to your computer and use it in GitHub Desktop.
std::string vtable_inator(const auto& any) {
struct h { void** name; };
return std::string(reinterpret_cast<char*>(reinterpret_cast<void**>(reinterpret_cast<const h*>(&any)->name[-1])[1]));
}
struct vtable_inator_able { virtual void nothing() final {}; };
struct Hello_world : vtable_inator_able {};
int main() {
std::print("{}\n", vtable_inator(Hello_world()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment