diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-03-30 18:09:10 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-03-30 18:09:10 +1100 |
commit | 83e2c574bdefe2d040cdfbe20a73380a0f0123dd (patch) | |
tree | 26bac5586a6c2cf40e837e280c3720ce13f39dbb /Max.h |
Initial commit. Basic Kleene iteration stuff.
Diffstat (limited to 'Max.h')
-rw-r--r-- | Max.h | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +#ifndef MAX_H +#define MAX_H + +#include "Expression.h" + +template<class T> +struct Max : public Expression<T> { + Max(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 ? right : left; + } + + private: + Expression<T>* _left; + Expression<T>* _right; +}; + +#endif |