fntraits.h

来自「精确的函数表达模板,里面包含了许多C和C++的函数表达模板」· C头文件 代码 · 共 67 行

H
67
字号

/****************************************************************************
 * 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.
 ****************************************************************************/

#ifndef fn_traits_h
#define fn_traits_h

   template <class T1, class T2>
   class Promote;

   // specialisations
   template <class T> class Promote<T, T>
   {
      public:
         typedef T promoted_t;
   };

   template <> class Promote<double, int>
   {
      public:
         typedef double promoted_t;
   };

   template <> class Promote<int, double>
   {
      public:
         typedef double promoted_t;
   };

   template <> class Promote<double, float>
   {
      public:
         typedef double promoted_t;
   };

   template <> class Promote<float, double>
   {
      public:
         typedef double promoted_t;
   };

   template <> class Promote<int, float>
   {
      public:
         typedef float promoted_t;
   };

   template <> class Promote<float, int>
   {
      public:
         typedef float promoted_t;
   };
#endif
 

⌨️ 快捷键说明

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