From Bjarn's paper here.
Same idea as before, but perhaps more clear.
template <bool b, class X, class Y>
struct if_ {typedef X type; };
template <class X, class Y>
struct if_ <false,x,y> { typedef Y type; };
void f() { if_<sizeof(foobar)<40,Foo,Bar>::type xy; }
Apparently, template programming is Turing complete.
Wednesday, June 6, 2007
More Monkey^wTemplate Magic
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment