Visual C++ Tail Call Optimization
问题 According to answers to that question: Which, if any, C++ compilers do tail-recursion optimization? it seems, that compiler should do tail-recursion optimization. But I've tried proposed options and it seems that compiler can't do this optimization in case of template functions. Could it be fixed somehow? 回答1: I don't use the MS compilers, but GCC can certainly do tail-recursion optimisation for templates. Given this function: template <typename T> T f( T t ) { cout << t << endl; if ( t == 0