Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef utl::Closure<utl::SExpr(utl::SExpr &)> EvalFunc;
- EvalFunc myclosure([=](utl::SExpr &in) ->utl::SExpr {
- if (auto i = in.getInt()) {
- return utl::SExpr(*i + 5);
- }
- return utl::SExpr();
- });
- utl::SExpr cexp(std::move(myclosure));
- utl::SExpr integer(1);
- auto func = cexp.getObj<EvalFunc>();
- if (func) {
- auto result = (*func)(integer);
- if (auto resulti = result.getInt()) {
- auto thisShouldBeA6 = *resulti;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement