#include enum { N = 5 }; struct nil { }; template struct cons { static const int car = car_; typedef cdr_ cdr; }; std::ostream& operator<<(std::ostream& o, const nil&) { return o; } template std::ostream& operator<<(std::ostream& o, const cons&) { return o << car_ << " " << cdr_(); } template struct nth { static const int val = nth::val; }; template struct nth { static const int val = list::car; }; template struct append { typedef cons::val> val; }; template struct append { typedef cons val; }; template struct foo { static const int val = !(nth::val == col || nth::val - r == col - row || N - 1 - nth::val - r == N - 1 - col - row) && foo::val; }; template struct foo { static const int val = 1; }; template struct bar; template struct baz : bar { }; template struct baz<0, queens, row> { }; template struct baz<1, queens, N> { baz() { std::cout << queens() << "\n"; } }; template struct bar : baz< foo::val, typename append::val, row + 1> , bar { }; template struct bar { }; baz<1, nil, 0> frob; int main() { }