Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide lazy proxies for algorithms #60

Open
brunocodutra opened this issue Feb 24, 2017 · 0 comments
Open

Provide lazy proxies for algorithms #60

brunocodutra opened this issue Feb 24, 2017 · 0 comments

Comments

@brunocodutra
Copy link
Owner

brunocodutra commented Feb 24, 2017

As shown by the example below, lazy proxies help reducing clutter when fancy composition is desired, the question is where to put them. One option would be within namespace metal::lazy, another would be to name them like shown below, so they could live at the root of namespace metal.

originally posted on cpplang.slack.com

using namespace metal;

template<typename... args>
using Transform = bind<lambda<transform>, args...>;

template<typename... args>
using If_ = bind<lambda<if_>, args...>;

template<typename... args>
using Invoke = bind<lambda<invoke>, args...>;

using lbd = Transform<If_<Invoke<_1, _2, _3>, _2, _3>, quote<l>>;

Given a predicate pred and unary lambdas f and g, you can then conditionally transform l with either f or g according to pred.

invoke<lbd, pred, f, g>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant