// SPDX-License-Identifier: MIT // Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved. #ifndef CK_FUNCTIONAL4_HPP #define CK_FUNCTIONAL4_HPP #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 { return ck::forward(f)(ck::forward(x).At(Number{})...); } }; 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 { return ck::forward(f)(ck::forward(x).At(Number{})..., ck::forward(y).At(Number{})...); } }; } // namespace detail template __host__ __device__ constexpr auto unpack(F&& f, X&& x) { using X_ = remove_reference_t; return detail::unpack_impl::type>{}( ck::forward(f), ck::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>{}( ck::forward(f), ck::forward(x), ck::forward(y)); } } // namespace ck #endif