Skip to content

Instantly share code, notes, and snippets.

@vivek-vijayan
Created August 30, 2022 17:45
Show Gist options
  • Save vivek-vijayan/20639140e22192a842704651598438f7 to your computer and use it in GitHub Desktop.
Save vivek-vijayan/20639140e22192a842704651598438f7 to your computer and use it in GitHub Desktop.
C++ programming for Meta
#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