【发布时间】:2015-07-25 15:39:12
【问题描述】:
我正在使用 Thrust 1.8,当我尝试编译以下代码时出现两个编译器错误:
#include <thrust/device_vector.h>
#include <thrust/functional.h>
int main(int argc, char* argv[])
{
thrust::device_vector<bool> condition(100);
thrust::device_vector<int> input(100);
thrust::device_vector<float> result(100);
float mean = 10.4f;
thrust::transform(condition.begin(),condition.end(),input.begin(),result.begin(), ( (thrust::placeholders::_1 ) ? ( thrust::placeholders::_2) : (mean) ) );
}
当我尝试编译时,我得到以下编译时错误:
(对于占位符::_1)
错误:表达式必须是 bool 类型(或可转换为 bool)
(对于占位符::_2)
错误:操作数类型不兼容(“const推力::detail::functional::actor >”和“float”)
如何解决这个问题?
【问题讨论】: