Skip to content

Instantly share code, notes, and snippets.

@qnighy
Created March 31, 2009 13:16
Show Gist options
  • Save qnighy/88182 to your computer and use it in GitHub Desktop.
Save qnighy/88182 to your computer and use it in GitHub Desktop.
#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