たらいまわし関数を C++ のテンプレートで作った
あとで書く.
#include <iostream> template<int x, int y, int z> struct tarai; template<int x, int y, int z, bool f> struct tarai_ { enum { value = tarai< tarai<x - 1, y, z>::value, tarai<y - 1, z, x>::value, tarai<z - 1, x, y>::value >::value }; }; template<int x, int y, int z> struct tarai_<x, y, z, true> { enum { value = y }; }; template<int x, int y, int z> struct tarai { enum { value = tarai_<x, y, z, (x <= y)>::value }; }; int main(void) { std::cout << tarai<20, 10, 5>::value << std::endl; return 0; }