#pragma once #include namespace DB { namespace detail { template static bool castTypeToEither(const auto * type, auto && f, std::index_sequence) { return ( (typeid_cast *>(type) ? std::forward(f)( *typeid_cast *>(type)) : false) || ...); } } template static bool castTypeToEither(const T * type, F && f) { /// XXX can't use && here because gcc-7 complains about parentheses around && within || return ((typeid_cast(type) ? f(*typeid_cast(type)) : false) || ...); } /// Use Common/TypeList as template argument template static constexpr bool castTypeToEitherTL(const auto * type, auto && f) { return detail::castTypeToEither( type, std::forward(f), std::make_index_sequence()); } }