[ create a new paste ] login | about

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

joel_f - C++, pasted on Nov 20:
#include <iostream>

template<int I, int N,class F>
struct for_
{
  for_() 
 {
    body_(I,N);
    for_<I+1,N,F> next;
 }

 F body_; 
};

template<int N, class F> struct for_<N,N,F> {};

struct display
{
  void operator()(int i,int n) { std::cout << i << std::endl; }
};

int main()
{
  for_<0,10,display> do_it;
}


Output:
1
2
3
4
5
6
7
8
9
10
0
1
2
3
4
5
6
7
8
9


Create a new paste based on this one


Comments: