10000 Provide lazy proxies for algorithms · Issue #60 · brunocodutra/metal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Provide lazy proxies for algorithms #60
Open
@brunocodutra

Description

@brunocodutra

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>;

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0