[Lambda] Protecting expressions with "mixed placeholders"
Hi all, Assuming "v" is an STL container, and "value" is a value the container can hold, I wish to do the following: ll::accumulate()(v.begin(), v.end(), true, _1 && (_2 != value)); which works: it returns true if all elements in the container are different from "value", false otherwise (might require a minute of thinking to come to that conclusion). Now I wish to make a lambda expression out of the above piece of code, which accepts "value" as the operator () argument, in order to be evaluated: bind(ll::accumulate(), v.begin(), v.end(), true, _1 && (_2 != value_placeholder)); where _1 and _2 should be protected but value_placeholder shouldn't (this is why I used "mixed placeholders" in the subject). In other words, should the bind-expression be evaluated with (value) as its operator() argument, only "value_placeholder" must be replaced by "value", the _1 or _2 placeholders must not. A simple protect: protect(_1 && (_2 != value_placeholder)) is obviously wrong, as "value_placeholder" cannot be replaced by "value" in an expression like: bind(ll::accumulate(), v.begin(), v.end(), true, protect(_1 && (_2 != value_placeholder)))(value); since "value_placeholder" itself, too, is protected. How to do this? I hope this was clear enough, I really tried. :-/ Regards, -- Irfy
participants (1)
-
Irfan Adilovic