Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1.          typedef utl::Closure<utl::SExpr(utl::SExpr &)> EvalFunc;
  2.  
  3.          EvalFunc myclosure([=](utl::SExpr &in) ->utl::SExpr {
  4.             if (auto i = in.getInt()) {
  5.                return utl::SExpr(*i + 5);
  6.             }
  7.             return utl::SExpr();
  8.          });
  9.  
  10.          utl::SExpr cexp(std::move(myclosure));
  11.          utl::SExpr integer(1);
  12.  
  13.          auto func = cexp.getObj<EvalFunc>();
  14.          if (func) {
  15.             auto result = (*func)(integer);
  16.             if (auto resulti = result.getInt()) {
  17.                auto thisShouldBeA6 = *resulti;
  18.             }
  19.          }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement