Lecture Notes for Advanced Programming II

6 May 2004 - Expression Templates


The template unary-expression class is

template < class Operand, class UnaryOp >
class unary_expression

  public:

    unary_expression(
      Operand e, UnaryOp op = UnaryOp())
      : expr(e), oprtr(op) { }

    result_type evaluate() const
      return oprtr(expr.evaluate())

  private:

    Operand expr
    UnaryOp oprtr


This page last modified on 6 May 2004.