Created
August 30, 2022 17:45
-
-
Save vivek-vijayan/20639140e22192a842704651598438f7 to your computer and use it in GitHub Desktop.
C++ programming for Meta
This file contains 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
#include <iostream> | |
template <int n> | |
struct factorial | |
{ | |
enum | |
{ | |
output = 2 * factorial<n - 1>::output | |
}; | |
}; | |
template <> | |
struct factorial<0> | |
{ | |
enum | |
{ | |
output = 1 | |
}; | |
}; | |
int main() | |
{ | |
std::cout << factorial<5>::output << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment