summaryrefslogtreecommitdiff
path: root/impl/Min.h
diff options
context:
space:
mode:
Diffstat (limited to 'impl/Min.h')
-rw-r--r--impl/Min.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/impl/Min.h b/impl/Min.h
new file mode 100644
index 0000000..9f17545
--- /dev/null
+++ b/impl/Min.h
@@ -0,0 +1,22 @@
+#ifndef MIN_H
+#define MIN_H
+
+#include "Expression.h"
+
+template<class T>
+struct Min : public Expression<T> {
+ Min(Expression<T>* left, Expression<T>* right)
+ : _left(left), _right(right) { }
+
+ T eval(const std::map<std::string, T>& mappings) const {
+ T left = _left->eval(mappings);
+ T right = _right->eval(mappings);
+ return left < right ? left : right;
+ }
+
+ private:
+ Expression<T>* _left;
+ Expression<T>* _right;
+};
+
+#endif