📄 expradapter.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: ExprAdapter
#ifndef __EXPRADPT_H //Required for current class
#define __EXPRADPT_H
#ifndef __EXPRINTR_H //Required for base classes
#include "ExprInterface.h"
#endif
// Concrete Expression (ADAPTER pattern)
template <class exprT>
class ExprAdapter
: public ExprInterface< typename exprT::argument_type
,typename exprT::result_type >
{
public:
typedef typename exprT expr_type;
typedef typename exprT::argument_type argument_type;
typedef typename exprT::result_type result_type;
private:
exprT expr;
public:
// Conversion constructor
ExprAdapter(const exprT& e) : expr(e) { ; }
// Copy Constructor
ExprAdapter(const ExprAdapter& anExprAdapter) : expr(anExprAdapter.expr) {}
// Clone
ExprInterface<argument_type, result_type>* clone() const
{ return new ExprAdapter(*this); }
//Operator=
ExprAdapter& operator= (const ExprAdapter& anExprAdapter)
{
if(&anExpr != this) expr = anExprAdapter.expr;
return *this;
}
// Evaluator
result_type operator() (const argument_type& x) const {return expr(x); }
// Destructor
virtual ~ExprAdapter() { }
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -