#include <stdio.h>
template <int i> void func(){}
template <> void func<1>(){ printf("func1\n"); }
template <> void func<2>(){ printf("func2\n"); }
template <> void func<3>(){ printf("func3\n"); }
template <int i> void foo(int x) { if (i==x) func<i>(); else foo<i+1>(x); }
template <> void foo<99>(int x){}
int main()
{
int i = 2;
foo<0>(i);
}