// SPDX-License-Identifier: MIT // Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved. #pragma once #include "sequence.hpp" #include "tuple.hpp" #include "array.hpp" namespace ck { namespace detail { template struct unpack_impl; template struct unpack_impl> { template __host__ __device__ constexpr auto operator()(F&& f, X&& x) const { #if 0 return std::forward(f)(std::forward(x).At(Number{})...); #else return std::forward(f)(std::forward(x).template At()...); #endif } }; template struct unpack2_impl; // TODO: remove this, after properly implementing unpack that takes any number of containers template struct unpack2_impl, Sequence> { template __host__ __device__ constexpr auto operator()(F&& f, X&& x, Y&& y) const { #if 0 return std::forward(f)(std::forward(x).At(Number{})..., std::forward(y).At(Number{})...); #else return std::forward(f)(std::forward(x).template At()..., std::forward(y).template At()...); #endif } }; } // namespace detail template __host__ __device__ constexpr auto unpack(F&& f, X&& x) { using X_ = remove_reference_t; return detail::unpack_impl::type>{}( std::forward(f), std::forward(x)); } // TODO: properly implement unpack that takes any number of containers template __host__ __device__ constexpr auto unpack2(F&& f, X&& x, Y&& y) { using X_ = remove_reference_t; using Y_ = remove_reference_t; return detail::unpack2_impl::type, typename arithmetic_sequence_gen<0, Y_::Size(), 1>::type>{}( std::forward(f), std::forward(x), std::forward(y)); } } // namespace ck