evandrix

[c++] monad - fix

Jul 13th, 2011
245
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template<int n> struct Const {};
  2. ...
  3. // compile Arg2 = getArg 1
  4. template<>
  5. struct Compile<Arg2> : GetArg<1> {};
  6. ...
  7. template<class L, class R>
  8. struct Compile<Times<L, R> > {
  9.   int operator()(Args args)
  10.   {
  11.     return Bind<Compile<L>, Bind<Compile<R>, Return> > (
  12.       Compile<L>(),
  13.       [](int left) -> Bind<Compile<R>, Return> {
  14.         return Bind<Compile<R>, Return>(
  15.           Compile<R>(),
  16.           [left](int right) -> Return {
  17.             return Return(left * right);
  18.           }
  19.         );
  20.       }
  21.     )(args);
  22.   }
  23. };
RAW Paste Data