📄 exprproxy.h
字号:
/****************************************************************************
* Copyright (C) 2001 Piece Wise Functions
* Carlo Galotto
* Italy
* Email: carlo.galotto@libero.it
* cgalotto@hotmail.com
*
*
* This framework is free software; you can redistribute it and/or modify
* it. This framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* The proposed framework is based upon the paper "Expression Templates" by
* Todd Veldhuizen.
****************************************************************************/
// Class: ExprProxy
#ifndef __EXPRPRXY_H //Required for current class
#define __EXPRPRXY_H
#ifndef __EXPRINTR_H //Required for base classes
#include "ExprInterface.h"
#endif
// Expression Proxy (PROXY pattern)
template <class argT, class resT>
class ExprProxy : public ExprInterface< argT, resT >
{
public:
typedef typename argT argument_type;
typedef typename resT result_type;
private:
ExprInterface<argT, resT>* expr;
public:
// Conversion and Default constructor
ExprProxy(ExprInterface<argT, resT>* e = 0) : expr(e) { }
// Copy constructor
ExprProxy(const ExprProxy& aProxy) : expr(aProxy.expr->clone())
{
;
}
// Destructor
virtual ~ExprProxy() { delete expr; }
// Assignement operator
void operator = (const ExprProxy& aProxy) {
if(this != &aProxy) {
if(expr != 0) {
expr = 0;
delete expr;
}
if(aProxy.expr != 0) expr = aProxy.expr->clone();
}
}
// Evaluator
result_type operator() (const argument_type& x) const
{ return expr ? (*expr)(x) : result_type(); }
// Clone
ExprInterface<argT, resT>* clone() const { return new ExprProxy(*this); }
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -