I'm trying to build a recursive function for an algorithm I currently have set up with for and while loops. However, it's possible that the function stacks thousands of function calls on top of the stack when in reality I would prefer them to be ignored, i.e. a conditional would tell me whether or not I want them or not.
So is there a way to pop off the stack the same way you can with std::stack? The stack I'm referring to using is just the default stack assigned when using any generic recursive function without specifying a custom stack like you could see with the standard library's stack.
I know the GCC can manage to optimize recursion with tail recursive calls by converting those calls into a loop, but I'm using g++ and it looks like tail recursion optimization is clunky to non-existent in g++
Aucun commentaire:
Enregistrer un commentaire