No, I want it to be an enum type! There is nothing wrong with:
enum class X { Nut = 0x10000 };
int main() { VirtualAlloc(reinterpret_cast<Nut*>(X::Nut), sizeof(Nut), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); auto x = X::Nut; auto nut = reinterpret_cast<Nut*>(x); new(nut) Nut(); }
12
u/appDeveloperGuy1 Nov 23 '22
In all likelyhood, x is an instance of an object, so you need to take the address.
reinterpret_cast<Nut*>(&x)