// Copyright (c) OpenMMLab. All rights reserved. #pragma once #include namespace turbomind { namespace detail { template inline constexpr std::integral_constant _Int{}; template bool dispatch_impl(F&& f, P&& p, G g, std::integer_sequence, std::index_sequence) { constexpr int N = sizeof...(Xs); return (((((P &&) p)(_Int) || (g && Is == N - 1)) && (((F &&) f)(_Int), 1)) || ...); } } // namespace detail template bool dispatch(std::integer_sequence seq, P&& p, F&& f, G g = {}) { return detail::dispatch_impl((F &&) f, (P &&) p, g, seq, std::make_index_sequence{}); } template bool dispatch(std::integer_sequence seq, F&& f) { return (((F &&) f)(detail::_Int) || ...); } } // namespace turbomind