]> git.tdb.fi Git - builder.git/blobdiff - source/booleanevaluator.cpp
Refactor BooleanEvaluator to have overloaded constructors
[builder.git] / source / booleanevaluator.cpp
index 074956a7a29b4cfddca039b1506eaaf30bf5dabb..6891abceff9a8088db506c6ea1388664830fb4f1 100644 (file)
@@ -3,11 +3,14 @@
 
 using namespace std;
 
-/* I'd rather have overloads with different slots, but that creates an
-ambiguity because slots have template constructors. */
-BooleanEvaluator::BooleanEvaluator(const Function &f, bool allow_compare):
+BooleanEvaluator::BooleanEvaluator(const ValueFunction &f):
+       func([&f](const string &value, const string *){ return f(value); }),
+       ops("&|!")
+{ }
+
+BooleanEvaluator::BooleanEvaluator(const CompareFunction &f):
        func(f),
-       ops(allow_compare ? "&|!=^" : "&|!")
+       ops("&|!=^")
 { }
 
 bool BooleanEvaluator::evaluate(const string &str)