Promotion.h

Go to the documentation of this file.
00001 #ifndef __PROMOTION_H__
00002 #define __PROMOTION_H__
00003 
00004 #include "libBaseTypes.h"
00005 
00006 template<class T1, class T2>
00007 class PromotionOf
00008 {
00009 public:
00010 };
00011 
00012 template<class T>
00013 class PromotionOf<T, T>
00014 {
00015 public:
00016   typedef T type;
00017 };
00018 
00019 #define DEFINE_SYMMETRICPROMOTION(T1,T2,TPromo)                                                      \
00020     template<> class PromotionOf<T1,T2>{public: typedef TPromo type;    }; \
00021     template<> class PromotionOf<T2,T1>{public: typedef TPromo type;    }; 
00022 
00023 #define PROMOTION(T1,T2) typename PromotionOf<T1,T2>::type
00024 
00025 //DEFINE_SYMMETRICPROMOTION(byte, Real, Real);
00026 //DEFINE_SYMMETRICPROMOTION(int, Real, Real);
00027 DEFINE_SYMMETRICPROMOTION(byte, int, int)
00028 ;
00029 
00030 DEFINE_SYMMETRICPROMOTION(byte, float, float)
00031 ;
00032 DEFINE_SYMMETRICPROMOTION(byte, double, double)
00033 ;
00034 DEFINE_SYMMETRICPROMOTION(short, float, float)
00035 ;
00036 DEFINE_SYMMETRICPROMOTION(short, double, double)
00037 ;
00038 DEFINE_SYMMETRICPROMOTION(int, float, float)
00039 ;
00040 DEFINE_SYMMETRICPROMOTION(int, double, double)
00041 ;
00042 DEFINE_SYMMETRICPROMOTION(float, double, double)
00043 ;
00044 
00045 template<class T>
00046 class RangePromotionOf
00047 {
00048 public:
00049   typedef T type;
00050 };
00051 
00052 #define DEFINE_RANGEPROMOTION(T,TPromo)                                                             \
00053     template<> class RangePromotionOf<T>{public:    typedef TPromo type;    }; 
00054 
00055 #define RANGEPROMOTION(T) typename RangePromotionOf<T>::type
00056 
00057 DEFINE_RANGEPROMOTION(byte,int)
00058 ;
00059 
00060 #endif //#ifndef __PROMOTION_H__

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1