summaryrefslogtreecommitdiff
path: root/impl/Operator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'impl/Operator.hpp')
-rw-r--r--impl/Operator.hpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/impl/Operator.hpp b/impl/Operator.hpp
index 2c5af75..c9b4a06 100644
--- a/impl/Operator.hpp
+++ b/impl/Operator.hpp
@@ -3,7 +3,6 @@
template<typename T>
T infinity() { }
-
template<>
float infinity() {
return INFINITY;
@@ -60,12 +59,24 @@ struct Constant : public Operator<T> {
template<typename T>
struct Addition: public Operator<T> {
- Addition(int i) : _value(i) { }
T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass) const {
- return (*args[0])(ass) + _value;
+ T sum = (*args[0])(ass);
+ for (unsigned int i = 1, size = args.size(); i < size; ++i) {
+ sum += (*args[i])(ass);
+ }
+ return sum;
+ }
+};
+
+template<typename T>
+struct Subtraction: public Operator<T> {
+ T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass) const {
+ T sum = (*args[0])(ass);
+ for (unsigned int i = 1, size = args.size(); i < size; ++i) {
+ sum -= (*args[i])(ass);
+ }
+ return sum;
}
- private:
- int _value;
};
#include "VariableAssignment.hpp"