[ create a new paste ] login | about

Link: http://codepad.org/IT95s8NV    [ raw code | output | fork ]

C++, pasted on Dec 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#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);
}


Output:
1
func2


Create a new paste based on this one


Comments: