C++相談室 part77
■ このスレッドは過去ログ倉庫に格納されています
0128これでいいよ
2010/01/23(土) 20:33:27struct 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();
}
■ このスレッドは過去ログ倉庫に格納されています