#pragma once #include namespace DB { /** StaticVisitor (and its descendants) - class with overloaded operator() for all types of fields. * You could call visitor for field using function 'applyVisitor'. * Also "binary visitor" is supported - its operator() takes two arguments. */ template struct StaticVisitor { using ResultType = R; }; /// F is template parameter, to allow universal reference for field, that is useful for const and non-const values. template auto applyVisitor(Visitor && visitor, F && field) { return Field::dispatch(std::forward(visitor), std::forward(field)); } template auto applyVisitor(Visitor && visitor, F1 && field1, F2 && field2) { return Field::dispatch( [&field2, &visitor](auto & field1_value) { return Field::dispatch( [&field1_value, &visitor](auto & field2_value) { return visitor(field1_value, field2_value); }, std::forward(field2)); }, std::forward(field1)); } }