1 | #include <iostream> |
2 | |
3 | #include <DataTypes/NumberTraits.h> |
4 | |
5 | |
6 | static void printType(DB::UInt8) { std::cout << "UInt8" ; } |
7 | static void printType(DB::UInt16) { std::cout << "UInt16" ; } |
8 | static void printType(DB::UInt32) { std::cout << "UInt32" ; } |
9 | static void printType(DB::UInt64) { std::cout << "UInt64" ; } |
10 | static void printType(DB::Int8) { std::cout << "Int8" ; } |
11 | static void printType(DB::Int16) { std::cout << "Int16" ; } |
12 | static void printType(DB::Int32) { std::cout << "Int32" ; } |
13 | static void printType(DB::Int64) { std::cout << "Int64" ; } |
14 | static void printType(DB::Float32) { std::cout << "Float32" ; } |
15 | static void printType(DB::Float64) { std::cout << "Float64" ; } |
16 | static void printType(DB::NumberTraits::Error) { std::cout << "Error" ; } |
17 | |
18 | template <typename T0, typename T1> |
19 | void ifRightType() |
20 | { |
21 | printType(T0()); |
22 | std::cout << ", " ; |
23 | printType(T1()); |
24 | std::cout << " -> " ; |
25 | printType(typename DB::NumberTraits::ResultOfIf<T0, T1>::Type()); |
26 | std::cout << std::endl; |
27 | } |
28 | |
29 | template <typename T0> |
30 | void ifLeftType() |
31 | { |
32 | ifRightType<T0, DB::UInt8>(); |
33 | ifRightType<T0, DB::UInt16>(); |
34 | ifRightType<T0, DB::UInt32>(); |
35 | ifRightType<T0, DB::UInt64>(); |
36 | ifRightType<T0, DB::Int8>(); |
37 | ifRightType<T0, DB::Int16>(); |
38 | ifRightType<T0, DB::Int32>(); |
39 | ifRightType<T0, DB::Int64>(); |
40 | ifRightType<T0, DB::Float32>(); |
41 | ifRightType<T0, DB::Float64>(); |
42 | } |
43 | |
44 | int main(int, char **) |
45 | { |
46 | printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::UInt8>::Type()); std::cout << std::endl; |
47 | printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::Int32>::Type()); std::cout << std::endl; |
48 | printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::Float32>::Type()); std::cout << std::endl; |
49 | printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt8, DB::UInt8>::Type()); std::cout << std::endl; |
50 | printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt16, DB::UInt8>::Type()); std::cout << std::endl; |
51 | printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt16, DB::Int8>::Type()); std::cout << std::endl; |
52 | printType(DB::NumberTraits::ResultOfFloatingPointDivision<DB::UInt16, DB::Int16>::Type()); std::cout << std::endl; |
53 | printType(DB::NumberTraits::ResultOfFloatingPointDivision<DB::UInt32, DB::Int16>::Type()); std::cout << std::endl; |
54 | printType(DB::NumberTraits::ResultOfIntegerDivision<DB::UInt8, DB::Int16>::Type()); std::cout << std::endl; |
55 | printType(DB::NumberTraits::ResultOfModulo<DB::UInt32, DB::Int8>::Type()); std::cout << std::endl; |
56 | |
57 | ifLeftType<DB::UInt8>(); |
58 | ifLeftType<DB::UInt16>(); |
59 | ifLeftType<DB::UInt32>(); |
60 | ifLeftType<DB::UInt64>(); |
61 | ifLeftType<DB::Int8>(); |
62 | ifLeftType<DB::Int16>(); |
63 | ifLeftType<DB::Int32>(); |
64 | ifLeftType<DB::Int64>(); |
65 | ifLeftType<DB::Float32>(); |
66 | ifLeftType<DB::Float64>(); |
67 | |
68 | return 0; |
69 | } |
70 | |