• Main Page
  • Namespaces
  • Data Structures
  • Files
  • File List

/export/development/ViennaMath/viennamath/compiletime/promote_traits.hpp

Go to the documentation of this file.
00001 #ifndef VIENNAMATH_COMPILETIME_PROMOTE_TRAITS_HPP
00002 #define VIENNAMATH_COMPILETIME_PROMOTE_TRAITS_HPP
00003 
00004 /* =======================================================================
00005    Copyright (c) 2012, Institute for Microelectronics,
00006                        Institute for Analysis and Scientific Computing,
00007                        TU Wien.
00008                              -----------------
00009                ViennaMath - Symbolic and Numerical Math in C++
00010                              -----------------
00011 
00012    Author:     Karl Rupp                          rupp@iue.tuwien.ac.at
00013 
00014    License:    MIT (X11), see file LICENSE in the ViennaMath base directory
00015 ======================================================================= */
00016 
00017 
00018 
00019 
00020 #include "viennamath/forwards.h"
00021 
00026 namespace viennamath
00027 {
00029    template <typename T, typename OP, typename U>
00030    struct promote_traits
00031    {
00032      typedef default_numeric_type  result_type;
00033    };
00034 
00036    template <typename T, typename OP>
00037    struct promote_traits <T, OP, T>
00038    {
00039       typedef T      result_type;
00040    };
00041    
00042    //to double:
00043    template <typename OP>
00044    struct promote_traits <double, OP, long>
00045    {
00046       typedef double      result_type;
00047    };
00048 
00049    template <typename OP>
00050    struct promote_traits <long, OP, double>
00051    {
00052       typedef double      result_type;
00053    };
00054 
00055    template <typename OP>
00056    struct promote_traits <double, OP, int>
00057    {
00058       typedef double      result_type;
00059    };
00060 
00061    template <typename OP>
00062    struct promote_traits <int, OP, double>
00063    {
00064       typedef double      result_type;
00065    };
00066    
00067    template <typename OP>
00068    struct promote_traits <double, OP, float>
00069    {
00070       typedef double      result_type;
00071    };
00072    
00073    template <typename OP>
00074    struct promote_traits <float, OP, double>
00075    {
00076       typedef double      result_type;
00077    };
00078    
00079    //to float:
00080    template <typename OP>
00081    struct promote_traits <float, OP, long>
00082    {
00083       typedef float      result_type;
00084    };
00085 
00086    template <typename OP>
00087    struct promote_traits <long, OP, float>
00088    {
00089       typedef float      result_type;
00090    };
00091    
00092    template <typename OP>
00093    struct promote_traits <float, OP, int>
00094    {
00095       typedef float      result_type;
00096    };
00097 
00098    template <typename OP>
00099    struct promote_traits <int, OP, float>
00100    {
00101       typedef float      result_type;
00102    };
00103    
00104    //special case: integer division:
00105    template <typename NumericType>
00106    struct promote_traits <long, op_div<NumericType>, long>
00107    {
00108       typedef default_numeric_type      result_type;
00109    };
00110 
00111    template <typename NumericType>
00112    struct promote_traits <long, op_div<NumericType>, int>
00113    {
00114       typedef default_numeric_type      result_type;
00115    };
00116    
00117    template <typename NumericType>
00118    struct promote_traits <int, op_div<NumericType>, long>
00119    {
00120       typedef default_numeric_type      result_type;
00121    };
00122    
00123    
00124 }
00125 
00126 #endif

Generated on Wed Feb 29 2012 21:50:43 for ViennaMath by  doxygen 1.7.1