コンパイルが止まらねぇー

(define fact/cps
  (lambda (n cont)
    (if (= n 0)
        (cont 1)
        (fact/cps (- n 1) (lambda (m) (cont (* n m)))))))

みたいな継続渡しスタイルの階乗計算をboost::mplでやってみた。
どこか間違えてるみたいで、コンパイルが停止しない。

#include <iostream>
#include <boost/mpl/arithmetic.hpp>
#include <boost/mpl/bind.hpp>
namespace mpl = boost::mpl;

namespace
{
  template <typename Integer, typename Cont>
  struct FactWithCps
  {
    static const int value =
      FactWithCps<
        mpl::minus<Integer, mpl::int_<1> >,
        mpl::bind<Cont, mpl::multiplies<Integer, mpl::_1> >
      >::value;
  };

  template <typename Cont>
  struct FactWithCps <mpl::int_<0>, Cont>
  {
    static const int value = Cont<mpl::int_<1> >::value;
  };
}

int main()
{
  std::cout << ::FactWithCps<mpl::int_<5>, mpl::_1>::value << "\n";
  return 0;
}

こんなの見ると、コンパイル==メタプログラムの実行を実感する。


さて、どこが間違ってるのかなぁ...。
typenameやらtemplateのキーワードの使い方もよく理解していない。
デバッグやりにくい。


Template Metaprogrammingやるのにもってこいの本。

C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ In-Depth Series)

C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ In-Depth Series)

いろんな本が中途半端で、こいつも3章くらいまでしか読んでない。
さて、読んでみますかな。