Created
March 31, 2009 13:16
-
-
Save qnighy/88182 to your computer and use it in GitHub Desktop.
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
#include <iostream> | |
template<int x, int y, int z> | |
struct tak; | |
template<int x, int y, int z, bool x_lte_y> | |
struct _tak | |
{ | |
static const int value = tak<tak<x-1,y,z>::value,tak<y-1,z,x>::value,tak<z-1,x,y>::value>::value; | |
}; | |
template<int x, int y, int z> | |
struct _tak<x, y, z, true> | |
{ | |
static const int value = y; | |
}; | |
template<int x, int y, int z> | |
struct tak | |
{ | |
static const int value = _tak<x, y, z, (x <= y)>::value; | |
}; | |
using namespace std; | |
int main(int argc, char *argv[], char *envp[]) | |
{ | |
cout << tak<1,2,3>::value << endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment