⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binaryfn.h

📁 精确的函数表达模板,里面包含了许多C和C++的函数表达模板
💻 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: BinaryFn

#ifndef __BINARYFN_H          //Required for current class
   #define __BINARYFN_H


#ifndef __EXPR_H               //Required for base class Expr
  #include "Expr.h"
#endif

#ifndef __EXPRPRXY_H           //Required for ExprProxy class
  #include "ExprProxy.h"
#endif

#ifndef __EXPRADPT_H           //Required for ExprAdapter class
  #include "ExprAdapter.h"
#endif

 // A shortcut for e.g. Expr< ExprProxy<float, float> > fn = FunctionMaker(espression);
   template <class argT, class resT = argT>
   class BinaryFn : public Expr< ExprProxy<argT, resT> > {

      public:
         //Default constructor
         BinaryFn() : Expr< ExprProxy<argT, resT> >() {}

         BinaryFn(ExprInterface<argT, resT>* e)
            : Expr< ExprProxy<argT, resT> >(e)  {}
   };

   // Converts an expression<exprT> to a BinaryFn<argT, resT>
   template <class exprT> inline
   BinaryFn<typename exprT::argument_type, typename exprT::result_type>
   FunctionMaker(const exprT & expr)
   {
      return BinaryFn< typename exprT::argument_type
                     , typename exprT::result_type>( new ExprAdapter<exprT>(expr) );

      // The dynamic allocated memory will be released automatically
      // by the destructor of the temporary BinaryFn that in turn will invoke
      // the destructor of the ExprProxy that in turn will delete the
      // dinamically allocated ExprAdapter object 
   }

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -