gpt4 book ai didi

c++ - 如何创建 thrust::device_vectors 的通用表

转载 作者:行者123 更新时间:2023-11-28 07:17:41 25 4
gpt4 key购买 nike

我创建了一个结构来构造一个表,其中的列是 thrust::device_vectors 并且 gcc 提示我没有传递模板参数。

struct table 
{
thrust::device_vector *columns;
};

error: argument list for class template "thrust::device_vector" is missing

我怎样才能让它变得通用,我可以为每一列设置任意类型的模板参数?

例如,一个表可以有 2 列:1 个浮点设备 vector 和一个整数设备 vector 。

最佳答案

编译器不知道要创建哪种类型的 device_vector。你应该这样使用

template <typename T> 
struct table
{
thrust::device_vector<T> *columns;
};

关于c++ - 如何创建 thrust::device_vectors 的通用表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19974251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com