简单程序中的意外推力错误
Unexpected Thrust error in simple program
使用Visual Studio 2017和The The Thrust库,我编译了以下程序:
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
template<int c>
struct computes_mod
{
auto operator()(int i) const
{
return i % c;
}
};
int main()
{
auto ti = thrust::make_transform_iterator(thrust::make_counting_iterator(0), computes_mod<3>{});
return 0;
}
但是,我得到以下编译器错误:
c2027使用未定义的类型'throust ::详细信息:: result_of_adaptable_function'
C3646'type':未知覆盖词
C4430缺少类型的指定词 - 假设INT。注意:C 不支持Default-Int
其细节以
给出1>main.cpp
1>c:program filesnvidia gpu computing toolkitcudav8.0includethrustdetailtype_traits.h(440): error C2027: use of undefined type 'thrust::detail::result_of_adaptable_function<UnaryFunc (int),void>'
1> with
1> [
1> UnaryFunc=computes_mod<3>
1> ]
1>c:program filesnvidia gpu computing toolkitcudav8.0includethrustiteratordetailtransform_iterator.inl(40): note: see declaration of 'thrust::detail::result_of_adaptable_function<UnaryFunc (int),void>'
1> with
1> [
1> UnaryFunc=computes_mod<3>
1> ]
1>c:program filesnvidia gpu computing toolkitcudav8.0includethrustiteratordetailiterator_adaptor_base.h(53): note: see reference to class template instantiation 'thrust::detail::eval_if<true,DefaultNullaryFn,thrust::detail::identity_<System>>' being compiled
1> with
1> [
1> DefaultNullaryFn=thrust::detail::result_of_adaptable_function<computes_mod<3> (int),void>,
1> System=thrust::use_default
1> ]
1>c:program filesnvidia gpu computing toolkitcudav8.0includethrustiteratordetailtransform_iterator.inl(41): note: see reference to class template instantiation 'thrust::detail::ia_dflt_help<Reference,thrust::detail::result_of_adaptable_function<UnaryFunc (int),void>>' being compiled
1> with
1> [
1> Reference=thrust::use_default,
1> UnaryFunc=computes_mod<3>
1> ]
1>c:program filesnvidia gpu computing toolkitcudav8.0includethrustiteratortransform_iterator.h(191): note: see reference to class template instantiation 'thrust::detail::transform_iterator_base<AdaptableUnaryFunction,Iterator,Reference,Value>' being compiled
1> with
1> [
1> AdaptableUnaryFunction=computes_mod<3>,
1> Iterator=thrust::counting_iterator<int,thrust::use_default,thrust::use_default,thrust::use_default>,
1> Reference=thrust::use_default,
1> Value=thrust::use_default
1> ]
1>[my_project]main.cpp(32): note: see reference to class template instantiation 'thrust::transform_iterator<computes_mod<3>,thrust::counting_iterator<int,thrust::use_default,thrust::use_default,thrust::use_default>,thrust::use_default,thrust::use_default>' being compiled
1>c:program filesnvidia gpu computing toolkitcudav8.0includethrustdetailtype_traits.h(440): error C3646: 'type': unknown override specifier
1>c:program filesnvidia gpu computing toolkitcudav8.0includethrustdetailtype_traits.h(440): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
我不确定为什么编译器会报告推力类型不确定,或者为什么我的代码会导致错误开始。在我看来,这就像 thrust::make_transform_iterator
的标准用法。
为什么会产生此错误?我该如何修复?
此外,如果很重要的话,我用标志编译了
/DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CPP /std:c++latest
谢谢您的帮助!
更新:上面的测试程序使用clang成功编译了。因此,问题似乎与VC 有关。
您必须包括定义类型result_of_adaptable_function
#include <thrust/detail/type_traits/result_of_adaptable_function.h>
应该做技巧。
您缺少适当的功能。
相关文章:
- vscode下的Arduino代码出现意外编译错误
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- C++标头错误 C2238 意外标记";"
- C++ 编译错误:意外的类型名称"字符串":预期的表达式
- 在gcc中意外调用了Const重载.编译器错误或兼容性修复程序
- "错误 C0000:语法错误,令牌"<EOF>"处出现意外$end,并且不确定
- boost::p rogram_options 在指定意外的位置参数时不报告任何错误
- 从 C++ 调用 cURL 命令会返回意外的错误代码,如 1792 和 6656
- Qt5 C++中出现意外"Multiple definition"错误
- 排序程序的意外错误代码
- 在 c++ 中声明向量时出现意外错误
- 函数调用中出现意外编译错误 (C++)
- 使用相同的函数时意外收到"std::out_of_range"错误
- 在第三个 pary 函数中使用矢量引用时出现意外错误
- 创建进程失败,意外错误
- 企业架构师错误:意外符号修复
- 在 Linux C++的两个线程之间使用管道的错误/意外行为
- Mex运行时错误:意外的标准表达式
- Cmake 奇怪的错误:语法错误意外的令牌 ('
- Cuda错误:意外启动失败