lundi 22 août 2016

C++14 Functional logical_not on functions

I have a logical expression, let's say !a & b. However, instead of evaluating this expression, I would like to build a functional tree and defer the evaluation to later. The values of a and b are computed using a function so we have:

auto value_of_a = std::bind(value, _1); //I need an additional argument
auto value_of_b = std::bind(value, _1);

I would like to use logical_not and logical_and instead of using my own lambdas. However, they call a direct operator on the argument (for instance !arg for logical_not). Therefore I cannot use something like:

auto v = std::bind(logical_not, value_of_a); //And we still need the first argument 
                                             //to call value_of_a

Can I bind the result (like some sort of Future) instead of the function?

I am trying to use as much already defined functions as possible for the sake of readability. I am using C++14 but those are defined in C++11.

Thanks, hope it is clear enough.

Aucun commentaire:

Enregistrer un commentaire