Vincent Hui (6) [Avatar] Offline
We know we must avoid stack overflow. However, how can we know how much free stack size left in run-time? So that we can handle low stack size condition in run-time.

Ivan Cukic (99) [Avatar] Offline
As far as I know, there is no portable way to do this. You could test it for each platform you run your program on and hard-code it (I've seen people doing this), but I would advise against it.

Stack size is not something you should rely on. Recursion is sometimes fun, but C++ is not the language where you want to overuse it.

There will be a possibility to achieve deep recursion in C++ with the coroutines language extension planned for C++20, but still, it is a hack and not something that should be (ab)used.