Last active
August 29, 2015 14:07
-
-
Save akarpov89/f2d8c5b4c043a8870831 to your computer and use it in GitHub Desktop.
Infinite recursion during compile expansion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <unsigned n> | |
unsigned fact() | |
{ | |
if (n == 0) | |
return 1; | |
// return n * fact<n - 1>(); <-- not compiles, infinite recursion | |
return n * fact<n - (n ? 1 : 0)>(); // OK | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment