struct
{
  template<class G>
    struct fixpt {
      G g;
      fixpt(G g) : g(g) {}
      int operator()(int x) { return g(fix(g))(x); }
    };
  template<class G>
    fixpt<G> operator()(G g) { return fixpt<G>(g); }
} fix;

struct fib_maker
{
  template<class F>
    struct fib {
      F f;
      fib(F f) : f(f) {}
      int operator()(int x) { return x<=1 ? 1 : f(x-1)+f(x-2); }
    };
  template<class F>
    fib<F> operator()(F f) { return fib<F>(f); }
} fib_maker;

#include <iostream>
int main()
{
  for( int i=0 ; i!=10 ; ++i )
    std::cout << fix(fib_maker)(i) << std::endl;

  // 作った関数を変数に留めておくには、
  //   boost::function<int(int)> fib = fix(fib_maker);
  // boost::function禁止なら、fixの型にfix_tとでも名前をつけて
  //   fix_t::fixpt<fib_maker> fib = fix(fib_maker);
}
