I am designing some APIs to allocate memory for DoA (data structure of arrays). One of the tasks is given a set of pointers and a size, how to allocate memory using cuda::std::tuple. I am having the following thinking to compile recursively for such a design:
template <typename IndexType, typename DataType>
cuda::std::tuple<DataType*> alloc_dev_mem_to_tuple(const IndexType num)
{
// some code to get a memory pool dm
DataType* ptr = dm->allocate(num * sizeof(DataType));
return cuda::std::make_tuple(ptr);
}
template <typename IndexType, typename... DataTypes>
cuda::std::tuple<DataTypes*...> alloc_dev_mem_to_tuple(const IndexType num)
{
}
However, it seems to me that this API is problematic from C++ perspective, as C++ functions are differentiated based on parameter list, not return type. How to implement such an idea then?