#pragma once #include namespace c10 { namespace detail { template struct overloaded_t {}; template struct overloaded_t : T0 { using T0::operator(); overloaded_t(T0 t0) : T0(std::move(t0)) {} }; template struct overloaded_t : T0, overloaded_t { using T0::operator(); using overloaded_t::operator(); overloaded_t(T0 t0, Ts... ts) : T0(std::move(t0)), overloaded_t(std::move(ts)...) {} }; } // namespace detail // Construct an overloaded callable combining multiple callables, e.g. lambdas template detail::overloaded_t overloaded(Ts... ts) { return {std::move(ts)...}; } } // namespace c10