ipapadop / deferred Goto Github PK
View Code? Open in Web Editor NEWLibrary for creating deferred evaluation expressions in C++
License: MIT License
Library for creating deferred evaluation expressions in C++
License: MIT License
A switch-case (series of if-else-if) is needed.
Proposed mechanism:
auto var = deferred::variable<int>();
auto ex = deferred::switch_(var,
deferred::default_("unknown"),
deferred::case_(10, [] { return "10"; }),
deferred::case_(12, [] { return "12"; }));
auto ex2 = deferred::switch_(ex, deferred::case_(11, [] { return "11"; }));
The functionality appears to be similar.
E.g.,
auto i = variable<int>();
auto loop = for_(i, i != 10, ++i, [&](auto&& i) { std::cout << i << '\n'; });
i = 2;
loop();
Implementation is similar to while
.
It also needs a function make_function_object
The information is duplicated, iterating over the subexpression types should tell if something is a constant expression.
The following code will have issues:
auto f()
{
auto c = constant(10);
auto c2 = c * 2;
return c2;
}
since c
will be stored as a reference in decltype(c2)
.
The lifetime of objects in valarray
's expressions is not properly extended (GCC/clang, the expression template mechanism keeps expressions as const&
).
A potential solution is to detect deferred
expressions that fail std::is_move_assignable
and std::is_copy_assignable
and store them in deferred::expression_
Support the following
auto ex = while_([] { return condition(); }, [] { expression(); });
ex();
If a deferred expression had the ability to call itself with some special keyword, then it should be possible to implement recursion.
Remove ref / rref from the type should happen at the call-site.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.