18 #ifndef itkPromoteType_h
19 #define itkPromoteType_h
37 template <
int N,
typename TA,
typename TB>
struct SizeToType;
43 template <
int N>
struct Identity {
typedef char Type[N]; };
50 #define ITK_ASSOCIATE(N, Typed)\
51 template <typename TA, typename TB> struct SizeToType<N,TA,TB> { using Type = Typed; };
56 ITK_ASSOCIATE(3,
short);
57 ITK_ASSOCIATE(4,
unsigned short);
58 ITK_ASSOCIATE(5,
int);
59 ITK_ASSOCIATE(6,
unsigned int);
60 ITK_ASSOCIATE(7,
long);
61 ITK_ASSOCIATE(8,
unsigned long);
62 ITK_ASSOCIATE(9,
long long);
63 ITK_ASSOCIATE(10,
unsigned long long);
64 ITK_ASSOCIATE(11,
float);
65 ITK_ASSOCIATE(12,
double);
66 ITK_ASSOCIATE(13,
long double);
90 template <
typename TA,
typename TB>
struct PromoteType
96 template <
typename T>
static Details::Identity<1>::Type& Check(
typename Details::SizeToType<1, TA, TB>::Type, T);
97 template <
typename T>
static Details::Identity<2>::Type& Check(
typename Details::SizeToType<2, TA, TB>::Type, T);
100 static Details::Identity<3 >::Type& Check(
typename Details::SizeToType<3, TA, TB>::Type,
int);
101 static Details::Identity<4 >::Type& Check(
typename Details::SizeToType<4, TA, TB>::Type,
int);
102 static Details::Identity<5 >::Type& Check(
typename Details::SizeToType<5, TA, TB>::Type,
int);
103 static Details::Identity<6 >::Type& Check(
typename Details::SizeToType<6, TA, TB>::Type,
int);
104 static Details::Identity<7 >::Type& Check(
typename Details::SizeToType<7, TA, TB>::Type,
int);
105 static Details::Identity<8 >::Type& Check(
typename Details::SizeToType<8, TA, TB>::Type,
int);
106 static Details::Identity<9 >::Type& Check(
typename Details::SizeToType<9, TA, TB>::Type,
int);
107 static Details::Identity<10>::Type& Check(
typename Details::SizeToType<10, TA, TB>::Type,
int);
108 static Details::Identity<11>::Type& Check(
typename Details::SizeToType<11, TA, TB>::Type,
int);
109 static Details::Identity<12>::Type& Check(
typename Details::SizeToType<12, TA, TB>::Type,
int);
110 static Details::Identity<13>::Type& Check(
typename Details::SizeToType<13, TA, TB>::Type,
int);
127 using Type =
typename Details::SizeToType<sizeof Check(a+b, 0), TA, TB>::Type;
135 #endif // itkPromoteType_h