Merge pull request #12341 from ClickHouse/aku/perfect-visitor

More perfect forwarding in field visitors
This commit is contained in:
Alexander Kuzmenkov 2020-07-11 13:36:37 +03:00 committed by GitHub
commit 10b0287fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,21 +40,24 @@ struct StaticVisitor
template <typename Visitor, typename F>
auto applyVisitor(Visitor && visitor, F && field)
{
return Field::dispatch(visitor, field);
return Field::dispatch(std::forward<Visitor>(visitor),
std::forward<F>(field));
}
template <typename Visitor, typename F1, typename F2>
auto applyVisitor(Visitor && visitor, F1 && field1, F2 && field2)
{
return Field::dispatch([&](auto & field1_value)
return Field::dispatch(
[&field2, &visitor](auto & field1_value)
{
return Field::dispatch([&](auto & field2_value)
return Field::dispatch(
[&field1_value, &visitor](auto & field2_value)
{
return visitor(field1_value, field2_value);
},
field2);
std::forward<F2>(field2));
},
field1);
std::forward<F1>(field1));
}