#pragma once #include #include #include namespace DB { template struct TypePair { using LeftType = T; using RightType = U; }; template bool callOnBasicType(TypeIndex number, F && f) { if constexpr (_int) { switch (number) { case TypeIndex::UInt8: return f(TypePair()); case TypeIndex::UInt16: return f(TypePair()); case TypeIndex::UInt32: return f(TypePair()); case TypeIndex::UInt64: return f(TypePair()); case TypeIndex::Int8: return f(TypePair()); case TypeIndex::Int16: return f(TypePair()); case TypeIndex::Int32: return f(TypePair()); case TypeIndex::Int64: return f(TypePair()); case TypeIndex::Int128: return f(TypePair()); case TypeIndex::Enum8: return f(TypePair()); case TypeIndex::Enum16: return f(TypePair()); default: break; } } if constexpr (_decimal) { switch (number) { case TypeIndex::Decimal32: return f(TypePair()); case TypeIndex::Decimal64: return f(TypePair()); case TypeIndex::Decimal128: return f(TypePair()); default: break; } } if constexpr (_float) { switch (number) { case TypeIndex::Float32: return f(TypePair()); case TypeIndex::Float64: return f(TypePair()); default: break; } } if constexpr (_datetime) { switch (number) { case TypeIndex::Date: return f(TypePair()); case TypeIndex::DateTime: return f(TypePair()); case TypeIndex::DateTime64: return f(TypePair()); default: break; } } return false; } /// Unroll template using TypeIndex template inline bool callOnBasicTypes(TypeIndex type_num1, TypeIndex type_num2, F && f) { if constexpr (_int) { switch (type_num1) { case TypeIndex::UInt8: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::UInt16: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::UInt32: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::UInt64: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Int8: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Int16: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Int32: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Int64: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Int128: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Enum8: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Enum16: return callOnBasicType(type_num2, std::forward(f)); default: break; } } if constexpr (_decimal) { switch (type_num1) { case TypeIndex::Decimal32: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Decimal64: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Decimal128: return callOnBasicType(type_num2, std::forward(f)); default: break; } } if constexpr (_float) { switch (type_num1) { case TypeIndex::Float32: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::Float64: return callOnBasicType(type_num2, std::forward(f)); default: break; } } if constexpr (_datetime) { switch (type_num1) { case TypeIndex::Date: return callOnBasicType(type_num2, std::forward(f)); case TypeIndex::DateTime: return callOnBasicType(type_num2, std::forward(f)); default: break; } } return false; } class DataTypeDate; class DataTypeString; class DataTypeFixedString; class DataTypeUUID; template class DataTypeEnum; template class DataTypeNumber; template class DataTypeDecimal; template bool callOnIndexAndDataType(TypeIndex number, F && f) { switch (number) { case TypeIndex::UInt8: return f(TypePair, T>()); case TypeIndex::UInt16: return f(TypePair, T>()); case TypeIndex::UInt32: return f(TypePair, T>()); case TypeIndex::UInt64: return f(TypePair, T>()); case TypeIndex::Int8: return f(TypePair, T>()); case TypeIndex::Int16: return f(TypePair, T>()); case TypeIndex::Int32: return f(TypePair, T>()); case TypeIndex::Int64: return f(TypePair, T>()); case TypeIndex::Float32: return f(TypePair, T>()); case TypeIndex::Float64: return f(TypePair, T>()); case TypeIndex::Decimal32: return f(TypePair, T>()); case TypeIndex::Decimal64: return f(TypePair, T>()); case TypeIndex::Decimal128: return f(TypePair, T>()); case TypeIndex::Date: return f(TypePair()); case TypeIndex::DateTime: return f(TypePair()); case TypeIndex::DateTime64: return f(TypePair()); case TypeIndex::String: return f(TypePair()); case TypeIndex::FixedString: return f(TypePair()); case TypeIndex::Enum8: return f(TypePair, T>()); case TypeIndex::Enum16: return f(TypePair, T>()); case TypeIndex::UUID: return f(TypePair()); default: break; } return false; } }