There are operator classes in STL like less, equal_to, greater_equal etc. How to easily combine them to use with for example remove_if function?
For example I want to remove in vector elements which are greater than 0 AND less than 3 AND not equal to 2, then it would be something like:
remove_if (v.begin(), v.end(), bind2nd(greater<int>(),0) + bind2nd(less<int>(),3) + not1(bind2nd(equal_to<int>(), 2)));
User during running of program can specify filtering options for example he can write: remove if x > 0 && x < 3 && x != 2, or he can write: remove if x > 5 || x == 3. Then command is parsed and appropriate operators with their arguments are combined together to one predicate.
This is rather simple in your case, actually.
You first need to parse the statement the user gave, and turn it into an AST (Abstract Syntax Tree). It turns out that this AST is nearly already suitable.
Can be expressed as a tree:
All nodes should inherit from a common base class, and you should implement a
Visitorto evaluate thexparameter for a given value.