30 namespace Expressions {
38 template <
class T,
class U>
64 virtual void print(std::ostream &,
int precedence = 99)
const;
83 template <
class T,
class U>
inline
86 fun(rhs.fun), opr(rhs.opr->clone())
90 template <
class T,
class U>
inline
93 fun(function), opr(oper)
97 template <
class T,
class U>
inline
102 template <
class T,
class U>
inline
108 template <
class T,
class U>
inline
111 U
arg = opr->evaluate();
112 T result = (*fun.function)(arg);
122 if(result ==
T(0))
return result;
133 template <
class T,
class U>
inline
138 bool isConst = operand->isConstant();
141 if(
function.precedence != -2) {
144 double value = result->evaluate();
154 template <
class T,
class U>
inline
156 if(fun.precedence >= 0) {
157 if(fun.precedence <= precedence) os <<
"(";
159 opr->print(os, fun.precedence);
160 if(fun.precedence <= precedence) os <<
")";
162 os << fun.name <<
"(";
170 #endif // OPAL_SUnary_HH
A scalar constant expression.
virtual Scalar< T > * clone() const
Make clone.
void operator=(const SUnary &)
virtual void print(std::ostream &, int precedence=99) const
Print expression.
Scalar< T > * release()
Release ownership.
static Scalar< T > * make(const TFunction1< T, U > &function, PtrToScalar< U > operand)
Make a new expression.
A function of one U, returning a T.
const TFunction1< T, U > & fun
boost::variant< nil, bool, unsigned int, double, identifier, boost::recursive_wrapper< unary >, boost::recursive_wrapper< function_call >, boost::recursive_wrapper< expression > > operand
virtual T evaluate() const
Evaluate.
A scalar expression with one scalar operand.