how do you store a function pointer in a std::stack?

Solved

I cannot compile the following without dozens of template errors

std::stack <void*()> functs; functs.push(funct);

I figured a solution would be to

std::stack <void*> functs;

But when I do this I cannot type cast the pointer to a function pointer

void (p)() = functs.top(); compiler error: invalid conversion from ‘void’ to ‘void (*)()’ [-fpermissive]

Posted Jul 21, 2017, 10:05 PM UTC

14
Loading comments…