#include <stdio.h>
struct Nil{};
template<int x, typename left, typename right> struct Tree{};
template<typename f, typename t> struct Iter;
template<typename f> struct Iter<f, Nil>{ static void invoke(){} };
template<typename f, int x, typename left, typename right> struct Iter<f, Tree<x,left,right> > {
static void invoke(){
f::template invoke<x>();
Iter<f, left>::invoke();
Iter<f, right>::invoke();
}
};
struct PrintIter {
template<int x>
static void invoke() {
printf( "[%d]\n", x );
}
};
typedef Tree<0, Tree<1, Tree<2, Nil, Nil>, Nil>, Tree<3, Nil, Nil> > test_tree;
int main()
{
Iter<PrintIter,test_tree>::invoke();
}