File indexing completed on 2024-04-06 12:01:17
0001 #ifndef CommonTools_Utils_ExpressionBinaryOperatorSetter_h
0002 #define CommonTools_Utils_ExpressionBinaryOperatorSetter_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "CommonTools/Utils/interface/parser/ExpressionBinaryOperator.h"
0014 #include "CommonTools/Utils/interface/parser/ExpressionStack.h"
0015 #include <cmath>
0016
0017 namespace reco {
0018 namespace parser {
0019
0020 template <typename T>
0021 struct power_of {
0022 T operator()(T lhs, T rhs) const { return pow(lhs, rhs); }
0023 };
0024
0025 template <typename T>
0026 struct int_div_remainder {
0027 T operator()(T lhs, T rhs) const { return int(lhs) % int(rhs); }
0028 };
0029
0030 template <typename Op>
0031 struct ExpressionBinaryOperatorSetter {
0032 ExpressionBinaryOperatorSetter(ExpressionStack& stack) : stack_(stack) {}
0033 void operator()(const char*, const char*) const {
0034 stack_.push_back(ExpressionPtr(new ExpressionBinaryOperator<Op>(stack_)));
0035 }
0036
0037 private:
0038 ExpressionStack& stack_;
0039 };
0040 }
0041 }
0042
0043 #endif