3 ms·
I wonder what the state of tail call optimization is in mainstream c++ compilers these days.
by fakedrake 11y ago
I wonder what the state of tail call optimization is in mainstream c++ compilers these days.
- lhecker 11y agoAFAIK most compiler will do tail-recursion optimization if the method ends in a tail call to the current function (obviously) or to a "sibling" function (i.e. if a() calls b() which calls a() again and so on) and is sufficiently short to be suitable for inlining. It's important to remember local objects with destructors will make this impossible, since destructors are run at the end of the function scope and thus after what's seemingly a perfect tail call.